1

I need to format my text in bold therefore I have several options for the same result. The main result would look like

\textbf{text in bold}

which works fine. But as soon as line breaks start to kick in the problem seems to get difficult. E.g.

\textbf{text

in bold}

Especially with the additional line break in between. LaTeX fails to compile. The log files indicate an introduced \par which seems to be in conflict with \textbf.

I found the solution for replace \textbf with {\bfseries ...}. Other solutions I found are italic (={\itshape...}, \texttt (={\ttfamily...})

I have the same problems for

  • \underline,
  • \textsubscript and
  • \textsuperscript

are there similar solutions as for the bold font available?

  • 1
    As for the \underline, have a look at this answer. I am wondering why you want to use subscript and superscript multiline. – user156344 Mar 11 at 14:05
  • All of the commands you mention are intended for use with small sections of text within a paragraph. If you want multiple paragraphs with a different font, size, marking, etc, then you should probably define a new environment that changes the text as you want it. – Thruston Mar 11 at 14:14
  • See (for example) tex.stackexchange.com/a/37251/15036 – Thruston Mar 11 at 14:18
  • @JouleV: Sorry but the approach for \underline has exactly the same result. @Thruston: I don't understand how to define a new environment. Just defining \newenvironment{myUL}[1]{\underline{#1}}{\par} will only format the very first char. And for the definition of a font: I want to use the regular font - just with e.g. underline – LeO Mar 11 at 14:40
2

\ul from soul accepts arguments with a \par/empty line in it:

\documentclass{book}
\usepackage{soul}

\begin{document}

\ul{text 

 text}
\end{document}

\par in \textsuperscript is imho senseless.

  • Thx - I'll test it tomorrow. I can somehow agree with your comment about the senseless par in ˋsuperscriptˋ. The problem is that the compiler ends with an error - ie. doesn't skip the senseless part. Its more about a valid TeX code than a meaningful code - Although I highly appreciate if it would work. – LeO Mar 11 at 17:07
  • So more or less the q remains: is there a way to avoid the error - for these special (corner) cases? e.g. tell LaTeX to ignore all linebreaks within e.g. ˋ\textsuperscriptˋ – LeO Mar 11 at 17:09
  • Yes, you can make all definitions long. But the reason that they are not is to get errors, if you forget a closing brace. Without it something like \textbf{some text will read your complete document while searching the end of the argument. – Ulrike Fischer Mar 11 at 17:15
  • Yeah, but how to do it practically? – LeO Mar 11 at 17:17
  • Well you look at the code and replace in all needed places \def by \long\def and similar. And as tests can change if a definition is suddenly long you should check for this too. – Ulrike Fischer Mar 11 at 17:23

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.