0

I am trying to create following listing

enter image description here

The template I have written is given below. But it is not properly indented.

 \documentclass[12pt]{article}
 % Packages used in template.
 \usepackage{enumitem}
 \usepackage{changepage}
 \usepackage{etoolbox}

 % Set left, right, top, and bottom margins of the paper.
 \usepackage[a4paper, left = 1.5in, right = 0.70in, top = 0.5in, bottom = 2.2in]{geometry}
 \voffset = 0.15in
 \headsep = 31pt
 \topmargin = -48pt

 % Create new environments for listings
 \setlist[enumerate]{wide, align=left, topsep = 0in, parsep = 0.24in, partopsep = 0in, itemsep = 0in, labelindent = 0in, labelsep = 0.36in}
 \newenvironment{FirstList}[1][]{ \begingroup \let \olditem \item
     \renewcommand \item {\olditem
     \ifnum\value{enumi} > 9
     \setlength\hskip{-0.14in}
     \fi
     \ifnum\value{enumi} > 99
     \setlength\hskip{-0.14in}
     \fi
     \ifnum\value{enumi} > 999
     \setlength\hskip{-0.14in}
     \fi
     }
     \begin{enumerate}[#1] } {\end{enumerate} \endgroup}

 \newenvironment{SecondList}{ \begin{adjustwidth}{0.48in}{0in}
     \begin{enumerate}}{ \end{enumerate} \end{adjustwidth}}

 \begin{document}
     \begin{FirstList}

        \item This template is made for A4 page size. I will try to extend this point into more than two lines.

        \item In this template,

        \begin{SecondList}
            \item Left margin is $\mathrm{1.5}$ in.

            \item Right margin is $\mathrm{0.7}$ in.

        \end{SecondList}

        \item This is another enumerated point.

         \begin{SecondList}
            \item This is another enumerated point.

            \item This is another enumerated point.
        \end{SecondList}

         \item This is another enumerated point.

    \end{FirstList}
 \end{document}
1
  • 1
    Is it purposely that the second line of the 1st item starts at the left margin, but the second line of the 10th item starts at the left margin of the list?
    – Bernard
    Mar 19, 2020 at 13:21

3 Answers 3

1

I edited your SecondList environment a little bit. The first list is what you've told that your output should look like. After thehrulefill is the output of what you gave in the MWI. Hope it helps you.

\documentclass[12pt]{article}
 % Packages used in template.
 \usepackage{enumitem}
 \usepackage{changepage}
 \usepackage{etoolbox}

 % Set left, right, top, and bottom margins of the paper.
 \usepackage[a4paper, left = 1.5in, right = 0.70in, top = 0.5in, bottom = 2.2in]{geometry}
 \voffset = 0.15in
 \headsep = 31pt
 \topmargin = -48pt

 % Create new environments for listings
 \setlist[enumerate]{wide, align=left, topsep = 0in, parsep = 0.24in, partopsep = 0in, itemsep = 0in, labelindent = 0in, labelsep = 0.36in}

 \newenvironment{FirstList}[1][]{ \begingroup \let \olditem \item
     \renewcommand \item {\olditem
     \ifnum\value{enumi} > 9
     \setlength\hskip{-0.14in}
     \fi
     \ifnum\value{enumi} > 99
     \setlength\hskip{-0.14in}
     \fi
     \ifnum\value{enumi} > 999
     \setlength\hskip{-0.14in}
     \fi
     }
     \begin{enumerate}[#1] } {\end{enumerate} \endgroup}

 \newenvironment{SecondList}[1][]{
    \begin{adjustwidth}{0.48in}{0in}
        \begin{enumerate}
            [#1]}{ % I added [#1], it worked.
        \end{enumerate}
    \end{adjustwidth}
    }

\begin{document}
    % This code will produce output like the image you provided.
    \begin{FirstList}
        \item This template is made for A4 page size. I will try to extend this point into more than two lines.

        \item In this template,
    \end{FirstList}
    \vspace{0.24in}
    \begin{SecondList}[label=(\alph*)]
        \item Left margin is $\mathrm{1.5}$ in.

        \item Right margin is $\mathrm{0.7}$ in.

        \begin{SecondList}[label=(\roman*)]
            \item Another nested item.

            \item Yet another nested item.

        \end{SecondList}

    \end{SecondList}
    \vspace{0.24in}
    \begin{FirstList}[label=(\theenumi)]
        \setcounter{enumi}{2}
        \item A theenumi item.

        \item Yet another theenumi item.
    \end{FirstList}

    \hrulefill
    \newline

    % This is the setting for the listing you provided.
    \begin{FirstList}
        \item This template is made for A4 page size. I will try to extend this point into more than two lines.

        \item In this template,

    \end{FirstList}

    \vspace{0.24in}

    \begin{SecondList}[label=(\alph*)]
        \item Left margin is $\mathrm{1.5}$ in.

        \item Right margin is $\mathrm{0.7}$ in.

    \end{SecondList}

    \vspace{0.24in}

    \begin{FirstList}[label=(\theenumi)]
        \setcounter{enumi}{2}
        \item This is another enumerated point.
    \end{FirstList}

    \vspace{0.24in}

    \begin{SecondList}[label=(\alph*)]
        \item This is another enumerated point.

        \item This is another enumerated point.
    \end{SecondList}

    \vspace{0.24in}     

    \begin{FirstList}[label=(\theenumi)]
        \setcounter{enumi}{3}
        \item This is another enumerated point.

    \end{FirstList}

\end{document}

EDIT: For multiple nesting

\documentclass[12pt]{article}
 % Packages used in template.
 \usepackage{enumitem}
 \usepackage{changepage}
 \usepackage{etoolbox}

 \newcommand{\adj}[1]{\begin{adjustwidth}{0.48in}{0in} #1 \end{adjustwidth}}

 % Set left, right, top, and bottom margins of the paper.
 \usepackage[a4paper, left = 1.5in, right = 0.70in, top = 0.5in, bottom = 2.2in]{geometry}
 \voffset = 0.15in
 \headsep = 31pt
 \topmargin = -48pt

 % Create new environments for listings
 \setlist[enumerate]{wide, align=left, topsep = 0in, parsep = 0.24in, partopsep = 0in, itemsep = 0in, labelindent = 0in, labelsep = 0.36in}

 \newenvironment{FirstList}[1][]{ \begingroup \let \olditem \item
     \renewcommand \item {\olditem
     \ifnum\value{enumi} > 9
     \setlength\hskip{-0.14in}
     \fi
     \ifnum\value{enumi} > 99
     \setlength\hskip{-0.14in}
     \fi
     \ifnum\value{enumi} > 999
     \setlength\hskip{-0.14in}
     \fi
     }
     \begin{enumerate}[#1] } {\end{enumerate} \vspace{0.24in} \endgroup}

 \newenvironment{SecondList}[1][]{
    \begin{adjustwidth}{0.48in}{0in}
        \begin{enumerate}[label=#1]
            }{ % I added [#1], it worked.
        \end{enumerate}
    \end{adjustwidth} \vspace{0.24in}
    }

\begin{document}
    % This code will produce output like the image you provided.
    \begin{FirstList}
        \item This is the first item in the first `FirstList' environment.
        \item This is the second item in the first `FirstList' environment. To start a secondary list, termination of this `FirstList' is necessary.
    \end{FirstList}
    \begin{SecondList}[(\alph*)]
            \item This is the first item of first nested list using `SecondList' environment.
            \item The second one
    \end{SecondList}
    \adj{
        \begin{SecondList}[(\alph*)]
            \item I've created an \texttt{\textbackslash adj} new command that will indent it properly.
            \item It'll also keep the second indentation proper.
        \end{SecondList}
    }
    \adj{
        \adj{
            \begin{SecondList}[(\alph*)]
                \item For multiple indentations use \texttt{\textbackslash adj} multiple times.
            \end{SecondList}
        }
    }
    \adj{
        \adj{
            \adj{
                \begin{SecondList}[(\alph*)]
                    \item For multiple indentations use \texttt{\textbackslash adj} multiple times.
                \end{SecondList}
            }
        }
    }
    \adj{
        \adj{
            \adj{
                \adj{
                    \begin{SecondList}[(\alph*)]
                        \item For multiple indentations use \texttt{\textbackslash adj} multiple times.
                    \end{SecondList}
                }
            }
        }
    }
\end{document}
7
  • Thank you for your reply. Please use following for in your document \begin{FirstList} \item This template is made for A1 page size. I will try to extend this point into more than two lines. \begin{SecondList} \item This template is made for A1 page size. I will try to extend this point into more than two lines. \begin{SecondList} \item This template is made for A1 page size. I will try to extend this point into more than two lines. \end{SecondList} \end{SecondList} \end{FirstList}
    – Ali Baig
    Mar 19, 2020 at 17:37
  • You will notice extra pair of brackets [] between one list and its nested list. Second when I try to define more than 3 levels of nested lists, the latex gives an error of too deep nesting. Other than that, your template works perfectly. Thank you.
    – Ali Baig
    Mar 19, 2020 at 17:38
  • Yes, I did notice it as well and to remove that extra bracket I did multiple \begin{FirstList} \end{FirstList}. To add the extra space to keep it consistent I added the \vspace{0.24in} Mar 19, 2020 at 18:41
  • Doing a FirstList -> SecondList creates the extra bracket. It is not necessary to do multiple nesting within the first FirstList. Like in the answer, you can change the counter and symbols for your listings. I haven't tried nesting multiple lists within a single FirstList, will give it a try at some later time. I'll see to multiple listing SecondList as well Mar 19, 2020 at 18:43
  • Thank you so much for your help.
    – Ali Baig
    Mar 19, 2020 at 19:01
1

Will this serve the purpose?

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage[a4paper, left = 1.5in, right = 0.70in, top = 0.5in, bottom = 2.2in]{geometry}
\voffset = 0.15in
\headsep = 31pt
\topmargin = -48pt
\newcounter{myenumi}
\renewcommand{\themyenumi}{%
\arabic{myenumi}.}
\newenvironment{myenumerate}{%
% stuff for beginning of environment goes here
\setlength{\parindent}{0pt}% don't indent paragraphs
\setcounter{myenumi}{0}% restart numbering
\bigskip% skip a line
\newcommand{\myitem}{% new definition of item
\par% start a new line
\refstepcounter{myenumi}% advance counter
\makebox[2em][l]{\themyenumi}% print counter to width of 3em, aligned to left
}% end of definition of item
}{% at end of environment
\par% start new paragraph
%\bigskip% skip a line
\noindent% don't indent new paragraph
\ignorespacesafterend% ignore spaces after environment
}

\begin{document}
\begin{myenumerate}
    \myitem Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text
    \myitem Text
    \renewcommand{\labelenumi}{(\alph{enumi})}
    \begin{enumerate}
        \itemindent=1em
        \itemsep=0pt
        \item Text
        \item Text
        \renewcommand{\labelenumii}{(\roman{enumi})}
        \begin{enumerate}
            \itemindent=0.6em
            \itemsep=0pt
            \item Text
            \item Text
        \end{enumerate}
    \end{enumerate}
    \renewcommand{\themyenumi}{(\arabic{myenumi})}
    \myitem Text
    \myitem Text
\end{myenumerate}
\end{document}
2
  • Niranjan Thank you for your reply. There are some issue with your MWE. 1) If an item is on two lines, the second line should start directly below the label. See the item 1 in the image in question. 2) The label of nested list should start directly below the text of parent list. See item (a) in the image posted in question. The label (a) is directly below the first letter of item 1 and 2.
    – Ali Baig
    Mar 19, 2020 at 17:15
  • @AliBaig please check the edit.
    – Niranjan
    Mar 20, 2020 at 4:38
0

Sorry, as far as I can see, you should simply read the documentation of enumitem carefully. Table 1 shows all the parameters that you need for indenting and the like. Then use \alph, \roman, and \arabic.

Define a \newlist. This is really helpful, once you get it.

Here is an example I made up quickly. You can adapt it to your needs.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{enumitem}

\begin{document}

\newlist{mylist}{enumerate}{3}
    \setlist[mylist,1]{label={\arabic*.}, resume, leftmargin=*, labelindent=\parindent, rightmargin=1.8\parindent, parsep={\parskip}, itemsep=0.3ex}
    \setlist[mylist,2]{label={(\alph*)}, leftmargin=2.2\parindent, rightmargin=1.8\parindent, itemsep=0.3ex, itemindent=10ex}
    \setlist[mylist,3]{label=\textbf{(\roman*)}, leftmargin=5\parindent, rightmargin=0\parindent, itemsep=0.3ex, itemindent=-5ex}

\begin{mylist}
\item one
\item two
\begin{mylist}
\item level two with a long text and a certain indent in the first and another in the following lines (also i played around with rightmargins just to show what is possible)
\begin{mylist}
\item level three with a long text and a certain indent in the first and another in the following lines (also i played around with rightmargins just to show what is possible)
\item second one here on level three
\end{mylist}
\item second one on level two
\end{mylist}
\end{mylist}
\begin{mylist}[labelsep=20ex]
\item three
\end{mylist}

\end{document}

So, I think this is much tidier than the other solutions. If some crucial feature of your list is missing and not easily realizable with enumitem, please comment on my answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .