TransWikia.com

Prevent Natbib from inserting newline after hbox immediately after bibitem

TeX - LaTeX Asked by Lupino on November 27, 2020

If I use a hbox to dimen right after bibitem, natbib seems to invoke a par break.Is there a way to avoid this or any other way to align the text after the em-dash with the other bibitems?

MWE:

documentclass[ngerman]{article}
usepackage{natbib}

bibhang=2emrelax
begin{document}
begin{thebibliography}{99}
bibitem[Herzer(1992)]{bib-01}Herzer, Manfred (1992), Magnus Hirschfeld. Leben und Werk eines jüdischen, schwulen und sozialistischen Sexologen, Frankfurt am Main.
bibitem[Herzer(1997)]{bib-02}hbox to bibhang{---} (1997), Das Wissenschaftlich-humanitäre Komitee, in: Goodbye to Berlin --- 100 Jahre Schwulenbewegung, hg. v. Schwulen Museum/Akademie der Künste, Berlin, S.~83–87.Hewitt, Andrew (1996), Political Inversions. Homosexuality, Fascism, and the Modernist Imaginary, Stanford, CA.
end{thebibliography}
end{document}

Result:

screenshot of MWE run

One Answer

When you use hbox, TeX will append it to the current list being built. If you are in horizontal mode (in a paragraph), TeX will append the hbox to the horizontal list, making it a part of the current paragraph (that's what you want). But if you are in vertical mode, then TeX will append that hbox to the current vertical list, more or less like it does for a line in a paragraph (that's what you are doing), so it looks like as the hbox stays in a paragraph of its own.

In plain TeX the solution would be to force the start of horizontal mode with leavevmode, then you make sure TeX puts the hbox in a horizontal list. In LaTeX (you can use leavevmode but) you should use makebox instead:

documentclass[ngerman]{article}
usepackage{natbib}

bibhang=2emrelax
begin{document}
begin{thebibliography}{99}
bibitem[Herzer(1992)]{bib-01}Herzer, Manfred (1992), Magnus Hirschfeld. Leben und Werk eines jüdischen, schwulen und sozialistischen Sexologen, Frankfurt am Main.
bibitem[Herzer(1997)]{bib-02}makebox[bibhang][c]{---}(1997), Das Wissenschaftlich-humanitäre Komitee, in: Goodbye to Berlin --- 100 Jahre Schwulenbewegung, hg. v. Schwulen Museum/Akademie der Künste, Berlin, S.~83–87.Hewitt, Andrew (1996), Political Inversions. Homosexuality, Fascism, and the Modernist Imaginary, Stanford, CA.
end{thebibliography}
end{document}

Correct answer by Phelype Oleinik on November 27, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP