TeX - LaTeX Asked on March 5, 2021
Note: This question is not about getting a desired visual effect in pdf, it is concerned with LaTeX/TeX internal algorithm.
In the following code, presence of sometimes produces a new internal tex-paragraph when encountered in the middle of a user-paragraph, and sometimes does not. In normal text mode, the only time it seems to not produce a new paragraph is when in fully-justified (default) alignment mode.
So the question is why did LaTeX team code this discrepancy? Was it to avoid changing the paragraph indentation for partial tex-paragraphs? Is it any better than starting a new paragraph with no indent in fully justified mode (like parvspace{1cm}noindent
instead of [1cm]
)?
Code (lualatex):
% >> lualatex par_vs_backslashes.tex
documentclass{article}
directlua{
nodetree = require"nodetree"
function filterprint(h)
nodetree.print(h)
return h
end
luatexbase.add_to_callback("pre_linebreak_filter",filterprint,"filterprint")
}
begin{document}
% This produces 2 tex-internal paragraphs
Hello[1cm] fooparvspace{1cm} world
raggedright
% This produces 3 tex-internal paragraphs
Hello[1cm] fooparvspace{1cm} world
end{document}
Console:
% Output for fully-justified mode:
├─LOCAL_PAR
├─HLIST subtype: indent, width: 15pt
├─GLYPH subtype: 256, char: H, width: 7.5pt, height: 6.83pt
├─GLYPH subtype: 256, char: e, width: 4.44pt, height: 4.48pt, depth: 0.11pt
├─GLYPH subtype: 256, char: l, width: 2.78pt, height: 6.94pt
├─GLYPH subtype: 256, char: l, width: 2.78pt, height: 6.94pt
├─GLYPH subtype: 256, char: o, width: 5pt, height: 4.48pt, depth: 0.11pt
├─ADJUST
│ ╚═head:
│ └─GLUE width: 28.45pt
├─PENALTY penalty: 10000
├─GLUE stretch: +1fil
├─PENALTY penalty: -10000
├─GLUE subtype: spaceskip, width: 3.33pt, stretch: 1.66pt, shrink: 1.11pt
├─GLYPH subtype: 256, char: f, width: 3.06pt, height: 7.05pt
├─GLYPH subtype: 256, char: o, width: 5pt, height: 4.48pt, depth: 0.11pt
├─KERN kern: 0.28pt
├─GLYPH subtype: 256, char: o, width: 5pt, height: 4.48pt, depth: 0.11pt
│ ╚═ properties: {['injections'] = {['leftkern'] = 18350.08}}
├─PENALTY subtype: linepenalty, penalty: 10000
└─GLUE subtype: parfillskip, stretch: +1fil
├─LOCAL_PAR
├─HLIST subtype: indent, width: 15pt
├─GLYPH subtype: 256, char: w, width: 7.22pt, height: 4.31pt, depth: 0.11pt
├─KERN kern: -0.28pt
├─GLYPH subtype: 256, char: o, width: 5pt, height: 4.48pt, depth: 0.11pt
│ ╚═ properties: {['injections'] = {['leftkern'] = -18350.08}}
├─GLYPH subtype: 256, char: r, width: 3.92pt, height: 4.42pt
├─GLYPH subtype: 256, char: l, width: 2.78pt, height: 6.94pt
├─GLYPH subtype: 256, char: d, width: 5.56pt, height: 6.94pt, depth: 0.11pt
├─PENALTY subtype: linepenalty, penalty: 10000
└─GLUE subtype: parfillskip, stretch: +1fil
% Output for rest of the modes (raggedright, etc):
├─LOCAL_PAR
├─HLIST subtype: indent
├─GLYPH subtype: 256, char: H, width: 7.5pt, height: 6.83pt
├─GLYPH subtype: 256, char: e, width: 4.44pt, height: 4.48pt, depth: 0.11pt
├─GLYPH subtype: 256, char: l, width: 2.78pt, height: 6.94pt
├─GLYPH subtype: 256, char: l, width: 2.78pt, height: 6.94pt
├─GLYPH subtype: 256, char: o, width: 5pt, height: 4.48pt, depth: 0.11pt
├─PENALTY subtype: linepenalty, penalty: 10000
└─GLUE subtype: parfillskip, stretch: +1fil
├─LOCAL_PAR
├─HLIST subtype: indent
├─GLYPH subtype: 256, char: f, width: 3.06pt, height: 7.05pt
├─GLYPH subtype: 256, char: o, width: 5pt, height: 4.48pt, depth: 0.11pt
├─KERN kern: 0.28pt
├─GLYPH subtype: 256, char: o, width: 5pt, height: 4.48pt, depth: 0.11pt
│ ╚═ properties: {['injections'] = {['leftkern'] = 18350.08}}
├─PENALTY subtype: linepenalty, penalty: 10000
└─GLUE subtype: parfillskip, stretch: +1fil
├─LOCAL_PAR
├─HLIST subtype: indent
├─GLYPH subtype: 256, char: w, width: 7.22pt, height: 4.31pt, depth: 0.11pt
├─KERN kern: -0.28pt
├─GLYPH subtype: 256, char: o, width: 5pt, height: 4.48pt, depth: 0.11pt
│ ╚═ properties: {['injections'] = {['leftkern'] = -18350.08}}
├─GLYPH subtype: 256, char: r, width: 3.92pt, height: 4.42pt
├─GLYPH subtype: 256, char: l, width: 2.78pt, height: 6.94pt
├─GLYPH subtype: 256, char: d, width: 5.56pt, height: 6.94pt, depth: 0.11pt
├─PENALTY subtype: linepenalty, penalty: 10000
└─GLUE subtype: parfillskip, stretch: +1fil
Output:
This predates "LaTex Team" involvement, and goes back to Leslie Lamport's original LaTeX versions, so I can't really say "why" just confirm that your observation is correct.
The documented behaviour of
is that it never ends the paragraph, it just forces a line break, however in centering
and similar settings
is redefined and does, as you say, internally use par
which is a shame as sometimes that implementation detail becomes observable eg when parskip
is non zero (although latex tries to hide that by adding a negative parskip space after the paragraph break introduced by
)
documentclass{article}
parskip=1in
begin{document}
begin{center}
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
zzzlinebreak zzz aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
end{center}
begin{center}
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
zzz zzz aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
end{center}
begin{center}
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
zzzpar zzz aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa aaaaa
end{center}
end{document}
Correct answer by David Carlisle on March 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP