How can I specify explicitly both the indentation of the label and the actual item's text from the left margin in a list environment. I would like to achieve the following:
[Tex/LaTex] Indentation in list environment
indentationlistsspacing
Related Solutions
To get enumerated and itemized lists that have the same amounts of left-hand and right-hand indentation, I'd recommend using the enumitem
package -- which provides many extensions to and improvements over LaTeX's list environments -- and its leftmargin
and rightmargin
options. The following MWE illustrates this.
\documentclass{article}
\usepackage[margin=3cm]{geometry} % per the example in your code
\usepackage{lipsum} % for filler text
\usepackage{enumitem}
\begin{document}
\lipsum[1] % filler text
\begin{enumerate}[leftmargin=2cm,rightmargin=2cm]
\item \lipsum[2]
\end{enumerate}
\lipsum[3]
\begin{itemize}[leftmargin=1cm,rightmargin=1cm]
\item \lipsum[4]
\end{itemize}
\end{document}
Added material after receiving a comment from the OP. I'm afraid I'm not quite sure about the meaning of the question
But how do I make the indentations of the \item the same as the original text?
The new MWE below provides four separate option settings for shaping the itemized (or, equivalently, enumerated) list items. Hopefully, one of these settings meets your needs.
\documentclass{article}
% some short filler text, ca. 3 lines long
\newcommand{\shortfiller}{Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, obortis vitae, ultricies et, tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna.}
\usepackage{fancyvrb}
\usepackage[margin=3cm]{geometry}
\usepackage{enumitem}
\begin{document}
\DefineShortVerb{\|}
\emph{``Normal'' text paragraph.} \shortfiller
%% Option 1
\begin{enumerate}[leftmargin=2cm, rightmargin=2cm]
\item \emph{Settings:} |[leftmargin=2cm, rightmargin=2cm]|.
\shortfiller
\end{enumerate}
\emph{``Normal'' text paragraph.} \shortfiller
%% Option 2
\begin{enumerate}[resume, wide=2cm, leftmargin=2cm, rightmargin=2cm]
\item \emph{Settings:} |[wide=2cm, leftmargin=2cm, rightmargin=2cm]|.
\shortfiller
\end{enumerate}
\emph{``Normal'' text paragraph.} \shortfiller
%% Option 3
\begin{enumerate}[resume, wide=\parindent, leftmargin=\parindent, rightmargin=\parindent]
\item \emph{Settings:} |[wide=\parindent, leftmargin=\parindent, rightmargin=\parindent]|.
\shortfiller
\end{enumerate}
\emph{``Normal'' text paragraph.} \shortfiller
%% Option 4
\begin{enumerate}[resume, wide=\parindent]
\item \emph{Setting in this and the following item:} |[wide=\parindent]|.
\shortfiller
\item \shortfiller
\end{enumerate}
\emph{``Normal'' text paragraph.} \shortfiller
\end{document}
Suppose the final setting of the list items is what you're looking for. If you want this setting to apply uniformly to all enumerated and itemized lists, you should insert the command
\setlist{wide=\parindent}
in your document's preamble, immediately after the \usepackage{enumitem}
instruction.
Best is to use the adjustwidth
environment offered by the changepage
package. It has the following format:
\begin{adjustwidth}{<leftmargin>}{<rightmargin>}
...
\end{adjustwidth}
The contents is indented from the left by <leftmargin>
and from the right by <rightmargin>
, as expected, and allows for page breaking:
\documentclass{article}
\usepackage{changepage}% http://ctan.org/pkg/changepage
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\lipsum[1-2]
\begin{adjustwidth}{3em}{0em}
\lipsum[3-6]
\end{adjustwidth}
\lipsum[7]
\end{document}
Here is a little bit of a hack: The standard quotation
environment (which typesets it's contents as a list) offered by LaTeX might be of some help here. Using this as foundation, the following MWE provides the shiftpar
environment. The optional argument specifies the left margin indent (default is 1.5em
, taken directly from the quotation
environment definition):
\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\makeatletter
\newenvironment{shiftpar}[1][1.5em]
{\list{}{%\listparindent #1%
\itemindent\parindent
\leftmargin#1
% \rightmargin\leftmargin
\parsep\z@\@plus\p@}%
\item\relax}
{\endlist}
\makeatother
\begin{document}
\lipsum[1-2]
\begin{shiftpar}[3em]
\lipsum[3-6]
\end{shiftpar}
\lipsum[7]
\end{document}
Best Answer
Your specifications are not very clear; the following could be what you need:
(As always, lipsum is used only to provide dummy text.)
If you want to be able to set the dimensions at usage time, you can define a personal environment, such as
to be called as
where the first argument is, in your notation, sep1 and the second argument is sep2.