TransWikia.com

"Retrotemporal" side effects (of centering, et al.)

TeX - LaTeX Asked by Hauke Reddmann on December 21, 2020

I solved the original problem in the meantime by trying all commands I found :-), but this could nevertheless be of interest. My style is llcns.

I just wanted to center a few paragraph headers such that they "jumped out" more. begin{center} wasn’t allowed, centering also gave a syntax error inside paragraph. The interesting stuff was when I placed centering before paragraph. That worked…too good. The whole subsection before it got centered too. "Luckily" my wacko idea of entering a dummy empty unnumbered subsection gave an unwanted vspace, God only knows what further side effects that would have brought, especially in the TOC…

But my obvious question is, how can a TeX command (centering isn’t the only one where I observed this behavior) affect something that happened before it? This runs against all my programmers instincts!

P.S. If you need to know: paragraphcenterline did the trick.

One Answer

A paragraph is broken in to lines based on the settings at the end of a paragraph so if you use centering mid-paragraph it affects the whole paragraph including earlier text.

Here centering is used just before the end of the paragraph but it is all centred.

documentclass{article}

begin{document}

fbox{Some long text that doesn't break} one fbox{Some long text that doesn't break}
fbox{Some long text that doesn't break} two two fbox{Some long text that doesn't break}
fbox{Some long text that doesn't break} three three three fbox{Some long text that doesn't break}
centering

end{document}

enter image description here

Note however the first line isn't quite centred as it has a paragraph indent on the left, parindent is set to 0 by centering but it is used too late here to affect the indentation box which has already been added.


It is hard to address your comments about paragraph: in the standard styles it is a run-in heading set within the first line of the paragraph so can not be centred.

To have centred paragraph headings you would want to make it a display heading.

enter image description here

documentclass{article}

begin{document}

section{Intro}
Section text
subsection{Something}
SubSection text
subsubsection{Other thing}
SubSubSection text
paragraph{4th level heading} 
Paragraph  text
end{document}

You can adjust the paragraph layout:

enter image description here

documentclass{article}

makeatletter
renewcommandparagraph{@startsection{paragraph}{4}{z@}%
                                     {-3.25ex@plus -1ex @minus -.2ex}%
                                     {1ex}% %inverting the signs so a display heading
                                     {normalfontnormalsizebfseriescentering}}% centering
makeatother
begin{document}

section{Intro}
Section text
subsection{Something}
SubSection text
subsubsection{Other thing}
SubSubSection text
paragraph{4th level heading} 
Paragraph  text
end{document}

Correct answer by David Carlisle on December 21, 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