1

I am trying to make my multiline labels aligned to the right. I applied style=multiline and align=right options to enumitem description environment. Here's the code describing the issues:

\documentclass{article}

\usepackage{geometry} \usepackage{enumitem}

\begin{document}

% multiline, left-aligned \begin{description}[style=multiline, leftmargin=!, labelwidth=4cm] \item[Truth-functional\ connective] A sentence connective with the property that the truth value of the newly formed sentence is determined solely by the truth value(s) of the constituent sentence(s), nothing more. \end{description}

% multiline, right-aligned; the option is not applied. \begin{description}[align=right, style=multiline, leftmargin=!, labelwidth=4cm] \item[Truth-functional connective] A sentence connective with the property that the truth value of the newly formed sentence is determined solely by the truth value(s) of the constituent sentence(s), nothing more. \end{description}

% the order of options changed; different result. \begin{description}[style=multiline, align=right, leftmargin=!, labelwidth=4cm] \item[Truth-functional connective] A sentence connective with the property that the truth value of the newly formed sentence is determined solely by the truth value(s) of the constituent sentence(s), nothing more. \end{description}

% The label aligned as intended with a single line label. \begin{description}[align=right, leftmargin=!, labelwidth=4cm] \item[Truth-functional] A sentence connective with the property that the truth value of the newly formed sentence is determined solely by the truth value(s) of the constituent sentence(s), nothing more. \end{description}

\end{document}

enter image description here

With a single-line label, there's no problem. But the options do not work correctly with a multiline label. Only the first and the last ones worked as intended. What's happening inside this code?

The desired output is

enter image description here

Hermis14
  • 423

1 Answers1

2

First, let's analyze, what's going on in your examples. For this, note that, as explained in enumitem's documentation, multiline is equivalent to style=standard,align=parleft,labelwidth=!.

  1. style=multiline, leftmargin=!, labelwidth=4cm

    This is working as intended: A fixed-width label with automatic line breaking. It is left-aligned due to parleft.

  2. align=right, style=multiline, leftmargin=!, labelwidth=4cm

    This is exactly the same thing, as style=multiline sets align=parleft, which overwrites the previous setting.

  3. style=multiline, align=right, leftmargin=!, labelwidth=4cm

    Setting align=right effectively undoes the central part of style=multiline (i.e. the part that creates the \parbox). I'm not sure why, but this leads to an Infinite glue shrinkage error when I run your example. Are you not getting this error? In theory, I would have expected this to be identical to the next case.

  4. align=right, leftmargin=!, labelwidth=4cm

    Here again you get what you expect: Right alignment, but no \parbox.


So how do we get what you want? The most straight-forward option is to just create a new alignment parright that does the same thing as parleft but with right alignment. We can just copy the definition from page 6 of the documentation and replace \raggedright with \raggedleft.

\documentclass{article}

\usepackage{geometry} \usepackage{enumitem}

\SetLabelAlign{parright}{\strut\smash{\parbox[t]\labelwidth{\raggedleft#1}}}

\begin{document}

% multiline, left-aligned \begin{description}[align=parright, leftmargin=!, labelwidth=4cm] \item[Truth-functional connective] A sentence connective with the property that the truth value of the newly formed sentence is determined solely by the truth value(s) of the constituent sentence(s), nothing more. \end{description}

\end{document}

MWE output

schtandard
  • 14,892
  • Thank you but I am a bit frustrated. How could I know all these things if you were not there? – Hermis14 Oct 12 '21 at 13:09
  • 1
    @Hermis14 Sometimes with TeX and friends considerable expertise is required to understand or solve a problem, which is only acquired through studying the subject extensively (i.e. you need to read a lot and gather experience). In this particular case, however, all of the necessary information was readily available in enumitem's documentation. (In fact, I did not know any of this three hours ago.) You can find it on CTAN or on your computer using texdoc enumitem (see this answer). – schtandard Oct 12 '21 at 14:53