AnswerBun.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}{[email protected]}%
                                     {[email protected] -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!

Related Questions

Solution environment with empty space below it

0  Asked on July 28, 2021 by aroosh

 

Marie Curie template citation style

1  Asked on July 28, 2021 by mikeg

   

Math mode not working

1  Asked on July 28, 2021 by chetan-annam

 

Fill inside a tikz path

1  Asked on July 28, 2021

 

easybmat matrices dotted lines

2  Asked on July 28, 2021 by yori

 

Tikz: Padding in finite automata nodes

0  Asked on July 28, 2021 by nicnajder

     

Big gap between chapter and text

0  Asked on July 28, 2021 by jonas-r

   

Flatfile comma and semicolon hightlight in lstlisting?

1  Asked on July 28, 2021 by petter-stergren

 

Place many TikZ drawings in one page

1  Asked on July 28, 2021 by ildar

   

Help with a header for a cls and tex

1  Asked on July 28, 2021 by nuno-m-silva

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP