The default leftmargin when using the enumitem package seems to be leftmargin=*, is there a way I can get the rightmargin to be the same width? The most obvious way would be rightmargin=* but that does not work, neither does rightmargin=leftmargin so I am beginning to expect I need to use the same value which enumitem uses internally. The text Customizing lists with the enumitem package says that when using arabic numbers the default is 0 which I have taken to understand as the width of glyph 0. If that is so maybe it is possible to get that length somehow and use it or how can this be accomplished?
Asked
Active
Viewed 8,439 times
8
David Carlisle
- 757,742
jonalv
- 11,466
2 Answers
9
The default is kinda labelindent=*. In version 3.0 (to be released next week) it is labelindent=*. With the key before you can execute code just before the list begins, ie, after all keys have been processed. So, just write:
\setlist{leftmargin=*,before=\setlength{\rightmargin}{\leftmargin}}
Javier Bezos
- 10,003
7
If the value of the rightmargin key is another length, this length must be specified including an escape character, i.e. rightmargin=\leftmargin.
EDIT: For whatever reason, this doesnt work with leftmargin=* added. It works, however, by emulating the calculations of leftmargin=* -- I used the calc package to do so conveniently.
\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{calc}
\usepackage{enumitem}
% Variant A doesn't work
% \setlist{leftmargin=*,rightmargin=\leftmargin}
% Variant B works
\setlist{labelwidth=\widthof{0.},leftmargin={\labelwidth+\labelsep},rightmargin=\leftmargin}
\begin{document}
\blindtext
\begin{itemize}
\item\blindtext
\end{itemize}
\end{document}
EDIT: Corrected emulation of \leftmargin=*. Thanks to Gonzalo and Javier!
lockstep
- 250,273
-
3Doing some tests, it seems that
leftmargin*uses\widthof{0.}instead of\widthof{0}forlabelwidth. I don't have much time now to verify this in the implementation of enumitem. – Gonzalo Medina Jun 23 '11 at 14:15 -
3Right -- it uses the width of the whole label, not only the counter. – Javier Bezos Jun 24 '11 at 17:34
leftmargin=*is smaller than the default. Also, why would you not want therightmarginto be 0 (that is, to be flush with the right margin of the surrounding text)? – Seamus Jun 23 '11 at 13:412.5emor thereabouts. 2: I'm not sure symmetry is always a good idea. Do you set all your section headings centred as well? – Seamus Jun 23 '11 at 13:57