TransWikia.com

leftmargin length not working in enumerate environment

TeX - LaTeX Asked by Bernhard on February 22, 2021

I need to write down arguments that are made up of numbered claims and where the conclusion is marked by a conclusion symbol. I have no problem modifying the way enumerate labels are displayed to have that result.

Unfortunately, these labels quickly get so wide that they hang over into the left margin. I’d like to indent the enumerate environment on the left so that the labels and the text are further to the right. Looking at a list of lengths in list environments (e.g., in this answer), I figured leftmargin would be the right length for me to manipulate. Unfortunately, it doesn’t have the expected effect of indenting the text associated with an item. I can use itemindent to indent the label, but that only indents the first line, not the main body.

A couple of constraints on answers.

  • I’m aware of the enumerate package and for various reasons do not want to use it.
  • I only want some, but not all, enumerate environments to be indented in this way. So a global change, e.g., by including AtBeginDocument{addtolength{leftmargini}{3em}} won’t work for me.

Here’s an MWE I’m working with, and a screenshot of the result. I’m using lipsum as an easy way to generate multiline text, and I’m calling amssymb to get me the "conclusion" symbol of the three dots.

documentclass{article}

usepackage{lipsum}
usepackage{amssymb}
begin{document}

lipsum[1]

begin{enumerate}
  renewcommand{theenumi}{roman{enumi}}%
  renewcommand{labelenumi}{(theenumi)}%
  addtolength{leftmargin}{5em}
  addtolength{itemindent}{3em}
item lipsum[4]
item lipsum[4]%
  renewcommand{labelenumi}{$therefore$(theenumi)}%
item lipsum[4]
end{enumerate}
end{document}

Output

3 Answers

You do not need to set addtolength{leftmargini}{3em} in the preamble it is a local declaration so can be set at any point before the special list. You can reset the value after the list either by using a tex group or simply subtracting the value after the list finishes.

It needs to be before begin{enumerate} not after as the value is used within the begin code to set up the list parameters.

Correct answer by David Carlisle on February 22, 2021

With enumitem is simple:

documentclass{article}
usepackage{lipsum}

usepackage{amssymb}
usepackage{enumitem}
setlist[enumerate]{label=(roman*),
                    itemindent=3em,
                    leftmargin=2em, % leftmargin=* if you like to have left margin as in main text
                    }

begin{document}
lipsum[11]

begin{enumerate}
item   lipsum[4]
item   lipsum[4]%
stepcounter{enumi}          % <---
item[$therefore$theenumi] % <---
        lipsum[4]
end{enumerate}
end{document}

enter image description here

Answered by Zarko on February 22, 2021

Is it what you want? I set the label width with enumitem, and asked to calculate the left margin in accordance:

documentclass{article}
usepackage{showframe}
renewcommand{ShowFrameLinethickness}{0.4pt}
usepackage{enumitem}
usepackage{lipsum}
usepackage{amssymb}

begin{document}

lipsum[1]

begin{enumerate}[labelwidth=2.5em, leftmargin=!]
item lipsum[4]
item lipsum[4]%
item[$therefore$ stepcounter{enumi}(theenumi)] lipsum[4]
end{enumerate}

end{document} 

enter image description here

Answered by Bernard on February 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP