0

The motivation for this question originates from the answer given to Centering an Arabic Section Number Above Justified Title Text

Consider the code

\documentclass{book}

\usepackage{titlesec} \titleformat{\section}[display] {\sffamily\Large\bfseries} {\filcenter\thesection} {1.25ex} {\justifycenter} \newcommand{\justifycenter}[1]{% \leftskip=0pt plus 1fil \rightskip=0pt plus -1fil \parfillskip=0pt plus 2fil #1% } \renewcommand{\thesection}{\arabic{section}.}

\begin{document} \large \thispagestyle{empty}

\section{Section Title on Which I Would Like to Employ the Linebreak Command; When I Do, Although the\break Output is Correct, I Receive an Error Message.\break However, No Such Error Message Results When I Use the Break Command.} \end{document}

which produces the desired output

enter image description here

In the code, I make use of the \break command in order produce a break in the line without losing the desired justification. I normally would use \linebreak, but for some reason unbenownst to me, it produced the desired result---though always with a series of error messages. Again, strangely, the command seemed to work, but not without a display of error messages.

After searching this site for an alternative to the \linebreak command, I came across the \break command---and it seems to work fine---no error messages.

QUESTION: In ordinary circumstances, is there any reason to prefer \break over \linebreak (or visa-versa)? Do they both do the same thing? After reading some comments pertaining to the use of \linebreak, it gave me the impression that one should use \linebreak it as little as possible, though I don't recall any specific reasons being given. What kinds of ``badness'' can be expected with the use of \linebreak? Do the same apply to \break?

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36
  • \break comes from plain and shouldn't be used in latex it is same as linebreak or pagebreak this is a dup, I'll find old answer.... – David Carlisle Jul 21 '22 at 06:15
  • probably \protect\linebreak or better use opt argument of section to put smaller title in table of contents – David Carlisle Jul 21 '22 at 06:19
  • 1
    https://tex.stackexchange.com/a/94220/1090 – David Carlisle Jul 21 '22 at 06:36
  • Also, don't ignore error messages. – user202729 Jul 21 '22 at 06:45
  • in a current latex \linebreak is robust and I get no errors from your example. – Ulrike Fischer Jul 21 '22 at 07:11
  • @UlrikeFischer yes I just updated the linked answer for post 2019 formats. – David Carlisle Jul 21 '22 at 07:29
  • Note (again:-) the advice is to avoid forced linebreaking and avoid formatting in section commands, not to avoid the specific command \linebreak The argument is used in the section head, the page head and the table of contents and you probably do not want the same break in all three. Hence "moving argument" If you get fragile command in moving argument errors, use \protect, or better, update your latex as \linebreak has not been fragile since the 2019 release. – David Carlisle Jul 21 '22 at 07:34
  • @DavidCarlisle The question linked is about \nolinebreak while this one is about \linebreak, so, although the issues are similar, I don't consider this question a duplicate of the linked one. – Ulrich Diez Jul 21 '22 at 18:16
  • @user202729 Seems the questioner did not intend to ignore error-messages, (s)he just did not have a clue what error-messages noticed are about. – Ulrich Diez Jul 21 '22 at 18:18
  • @UlrichDiez you do know that they share almost all their code and just differ by a - – David Carlisle Jul 21 '22 at 18:20
  • @DavidCarlisle You know and I know, but a novice asking questions most likely does not know. – Ulrich Diez Jul 21 '22 at 18:21
  • sure but questions about subsections get closed as dup of questions about sections, and questions about any missing % get closed as dup of a question about % at eol. and this is far closer. But democracy at work, vote to re-open and if 4 people agree feel free to answer. – David Carlisle Jul 21 '22 at 18:44
  • @DavidCarlisle I won't - your clarification is sufficient. ;-) – Ulrich Diez Jul 21 '22 at 22:40

0 Answers0