Skip to content

\raggedright \parfillskip incorrect with \DocumentMetadata #2015

@arthomnix

Description

@arthomnix

Brief outline of the bug

When using \DocumentMetadata, the \raggedright command sets \parfillskip to 0pt. This doesn't match the standard LaTeX definition of \raggedright, which uses the default \parfillskip value of 0pt plus 1fil.

Minimal example showing the bug

(I haven't included latexbug in this example because of latex3/tagging-project#1229)

\DocumentMetadata{lang=en} % compare with \DocumentMetadata removed
\documentclass{article}

\begin{document}
{\raggedright\typeout{\the\parfillskip}}
\end{document}

prints 0.0pt to the log. If the \DocumentMetadata command is removed, this prints 0.0pt plus 1.0fil.

Although this is a latex-lab bug, the effects are probably best demonstrated with TikZ's text width option (which uses \raggedright internally, but overrides \rightskip, \spaceskip and \xspaceskip):

\DocumentMetadata{lang=en} % compare with \DocumentMetadata removed
\documentclass{article}
\usepackage{tikz}

\begin{document}
\tikz\node[text width=3cm] {Lorem ipsum dolor sit amet};
\end{document}

Notice that the content of the node is set differently than with \DocumentMetadata removed. If you replace the content of the node with something narrower than 3cm (e.g. \tikz\node[text width=3cm] {foo};), you get an underfull hbox warning that does not occur without \DocumentMetadata. This bug causes noticeably worse line breaking in some of my real-world TikZ diagrams.

Cause

In latex-lab-block, the raggedright para instance has end-hspace = \z@skip:

\DeclareInstance{para}{raggedright}{std}
{
,para-attr-class = raggedright
,para-indent = 0pt
% ,begin-hspace = 0pt
,left-hspace = \z@skip
,right-hspace = \@flushglue
,end-hspace = \z@skip
,final-hyphen-demerits = 0
,newline-cmd = \@centercr
}

This should probably be \@flushglue to match the standard LaTeX definition of \raggedright.

Log file (required) and possibly PDF file

First example:
test.log
test_nodocumentmetadata.log

TikZ example:
test_tikz.log
test_tikz.pdf
test_tikz_nodocumentmetadata.log
test_tikz_nodocumentmetadata.pdf

Second TikZ example (underfull hbox):
test_tikz2.log
test_tikz2_nodocumentmetadata.log

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions