4

I am typing some category theory and I am unsure how to handle the name of a category in LaTeX. I read the post

How to typeset the name of a category?

and implemented the mathbf-solution mentioned there, but I still have the following problem: I would like to give my categories names that are as telling as possible. For instance, the category of compact Riemannian Spin manifolds should be something like "CpctRiemSpinMfd" and not something like "cRSM". This practice makes the text much simpler to read for readers unfamiliar with the notation, but also makes the names of the categories rather long. This completely ruins the linebreaking when a name of a category occurs at the end of a line within the text. The name is printed on the right margin far beyond the usual border. How to fix that? I want to use the names of my categories inside the text and inside mathmode.

MWE

\documentclass{article}

\newcommand{\cat}[1]{\mathbf{#1}}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas $\cat{RiemSpinMfd}$ aliquam nisi elit, non bibendum tortor gravida mattis. Praesent non sem ultrices dolor commodo sodales vel ac leo. 


\end{document}
  • I can't see any way out, except allowing line breaks in the middle of a name, but this would probably be confusing. – egreg Feb 18 '14 at 11:24
  • 2
    Another approach would be to use the short standard names in the document, but create a well designed glossary for people new to the subject. You could even make the short names into links. If that interrupts the text flow too much, put the links in the margin. This also highlights the used terms. – bodo Feb 18 '14 at 11:28
  • It is not like that is good practice, but you could add \sloppy to your preamble. It will allow Latex to break the line even when there is too much space to fill with the few words before the linebreak. – Jesko Hüttenhain Feb 18 '14 at 12:14
4

Long unbreakable objects are always a problem for good typesetting. I'd personally go with short names.

You can bend LaTeX to break the names, though. I'd do it only in otherwise unsolvable situations; rewording paragraphs is usually the best way to solve bad line breaks.

\documentclass{article}

\sbox0{$\mathbf{\xdef\mybffam{\the\fam}}$}
\newcommand{\cat}[1]{\begingroup\fam\mybffam#1\endgroup}
\newcommand{\?}{\penalty0 }


\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas $\cat{Riem\?SpinMfd}$
aliquam nisi elit, non bibendum tortor gravida mattis. Praesent non sem ultrices dolor
commodo sodales vel ac leo.

\renewcommand{\?}{\discretionary{-}{}{}}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas $\cat{Riem\?SpinMfd}$
aliquam nisi elit, non bibendum tortor gravida mattis. Praesent non sem ultrices dolor
commodo sodales vel ac leo.

\end{document}

The first paragraph shows that the long name is split at \? without any marker; with a redefinition of \? a hyphen can be inserted, instead. Choose your method and insert \? only where it's absolutely unavoidable.

enter image description here

  • However, hyphenation is handled automatically in textmode. Maybe one could change the command such that it uses \mathbf in mathode and \textbf in textmode? – Meneldur Feb 26 '14 at 9:58
  • @Meneldur I'd be very cautious: automatic hyphenation of “CpctRiemSpinMfd” would give “Cpc-tRiem-Spin-Mfd” and you surely don't want it. – egreg Feb 26 '14 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.