How to disable indentation of LaTeX list items? [closed]

房东的猫 提交于 2019-12-03 16:30:04

问题


By default the "enumerate" environment is indented with respect to the current environment. How can I disable this indentation so that an enumerate environment of three items would produce the same output as the following piece of code?

\documentclass{article}
\begin{document}
  \paragraph{1.}
  \paragraph{2.}
  \paragraph{3.}
\end{document}

回答1:


Your best bet is probably to use either the mdwlist package or the enumlist package.

Or this website suggests the use of the list environment like this:

\begin{list}{\labelitemi}{\leftmargin=1em}
\item First item in the list
\item Second item
\item and so on
\end{list}

which suggests that you could redefine the length leftmargin in your enumeration if you prefer. Something like:

\newenvironment{flushenum}{
\begin{enumerate}
  \setlength{\leftmargin}{0pt}
}{\end{enumerate}}

which seems to work for me..




回答2:


This question appears to be dead, but in case somebody wanders across it as I did, there is also the paralist package which provides asparaitem and asparaenum environments, which do precisely this.

paralist also provides the inparaenum environment, which is designed for in-paragraph lists: something like "There are three ways to get there: one can (1) turn left, (2) turn right, or (3) go straight." You could use this environment and if you want you can insert your own paragraph breaks. This gives a flush enumerate but with indentation at the beginning of a paragraph. If it comes to that, maybe you should just use \paragraph.




回答3:


I compiled the three suggested methods into one file to be able to compare them side by side. Note that \setlength{\leftmargin}{0pt} does not have any effect on the "enumerate" environment. So far, the best solution is the "list" environment using the option "\leftmargin=1.4em". However, I do not like a constant number in my code for it makes the code fragile. Does anyone know how to compute this constant (1.4em) in terms of available LaTeX variables?

\documentclass{article}
\begin{document}

\section*{Paragraph}
\paragraph{1.} First
\paragraph{2.} Second
\paragraph{3.} Third

\section*{list}

\newcounter{itemcounter}
\begin{list}
{\textbf{\arabic{itemcounter}.}}
{\usecounter{itemcounter}\leftmargin=1.4em}
\item First
\item Second
\item Third
\end{list}

\section*{enumerate with leftmargin}
\begin{enumerate}
\renewcommand{\labelenumi}{\textbf{\theenumi}.}
\setlength{\leftmargin}{0pt}
\item First
\item Second
\item Third
\end{enumerate}

\end{document}


来源:https://stackoverflow.com/questions/1427005/how-to-disable-indentation-of-latex-list-items

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!