4

I try to align some text to the bullets of an itemize-list. How to do so properly?

I found a workaround but that is quite ugly. Is there a better way to do so? Maybe a variable with the exact bullet indentation?

Thank you :)

Here is an MWE:

\documentclass[a4paper, 12pt, parskip]{scrreprt}

\begin{document}
This is a normal text that should be left aligned.

\mbox{\hspace{16.5pt}This} is another text over multiple lines that I want to have aligned equally to the\\
\mbox{\hspace{16.5pt}bullets} of the following list:

\begin{itemize}
  \item This is item 1.
  \item And this is a second item.
\end{itemize}

\end{document}

enter image description here

1
  • @barbarabeeton True, I don't know what I was thinking... :-(
    – campa
    Mar 4, 2020 at 19:36

4 Answers 4

2

The oddity about regular lists are that their labels or set right-aligned. The following indentitem environment emulates that approach, indenting to the correct location of the item content, and then stepping back the width of \textbullet.

enter image description here

\documentclass[a4paper,12pt,parskip]{scrreprt}

\usepackage{changepage}

\makeatletter
\newenvironment{indentitem}{%
  \sbox\@tempboxa{\textbullet}%
  \begin{adjustwidth}{\dimexpr\itemindent+\labelwidth-\wd\@tempboxa}{0pt}%
}{%
  \end{adjustwidth}%
}
\makeatother

\begin{document}

This is a normal text that should be left aligned.

\mbox{\hspace{16.5pt}This} is another text over multiple lines that I want to have aligned equally to the \\
\mbox{\hspace{16.5pt}bullets} of the following list:

\begin{itemize}
  \item This is item 1.
  \item And this is a second item.
\end{itemize}

\noindent\hrulefill

This is a normal text that should be left aligned.

\begin{adjustwidth}{16.5pt}{0pt}
  This is another text over multiple lines that I want to have aligned equally to the
  bullets of the following list:
\end{adjustwidth}

\begin{itemize}
  \item This is item 1.
  \item And this is a second item.
\end{itemize}

\noindent\hrulefill

This is a normal text that should be left aligned.

\begin{indentitem}
  This is another text over multiple lines that I want to have aligned equally to the
  bullets of the following list:
\end{indentitem}

\begin{itemize}
  \item This is item 1.
  \item And this is a second item.
\end{itemize}

\end{document}
1

Here is a solution that based on Possible to create bullets for \subitems using \itemize without a nested list? .

Whenever you want the text aliged as you show, use \SubItem instead of the usual \item. Then

This is a normal text that should be left aligned.

\begin{itemize}
  \item normal list text
  \SubItem This is second text over multiple lines that I want to have aligned
    equally to the to the following list
  \item This is item 1.
  \SubItem This is third text over multiple lines that I want to have aligned
    equally to the to the following list
  \item And this is a second item.
\end{itemize}

produces

enter image description here

Notes:

  • For the case where the \SubItem is the first entry in the list, this require the use of \IgnoreMissingItemError% (commented out in the MWE below).

Warning:

Code:

\documentclass[a4paper, 12pt, parskip, headsepline]{scrreprt}
\usepackage{enumitem}


\makeatletter
%% Allow for lists to have no items.
%% https://tex.stackexchange.com/q/86547/4301
\newcommand\IgnoreMissingItemError{\let\@noitemerr\relax}
\makeatother

\newlength\WidthOfBullet
\settowidth\WidthOfBullet{$\bullet$}

%% https://tex.stackexchange.com/a/84235/4301
\newlist{SubItemList}{itemize}{1}
\setlist[SubItemList]{label={},left=-\dimexpr\labelsep+\WidthOfBullet+1.0ex\relax}

\let\OldItem\item
\newcommand{\SubItemStart}[1]{%
    \let\item\SubItemEnd
    \begin{SubItemList}[resume]%
        \OldItem #1%
}
\newcommand{\SubItemEnd}[1]{%
    \end{SubItemList}%
    \let\item\OldItem
    \item #1%
}
\newcommand*{\SubItem}[1]{%
    \SubItemStart{#1}%
}%

\begin{document}
This is a normal text that should be left aligned.

\begin{itemize}
  %\IgnoreMissingItemError% <--- Need this if want to use \SubItem as first "item"
  %\SubItem This is frist text over multiple lines that I want to have aligned
  % equally to the to the following list
  \item normal list text
  \SubItem This is second text over multiple lines that I want to have aligned
    equally to the to the following list
  \item This is item 1.
  \SubItem This is third text over multiple lines that I want to have aligned
    equally to the to the following list
  \item And this is a second item.
\end{itemize}

\end{document}
1

I combined your answers to make it working quite well. Thank you very much!

It is working with this code:

\documentclass[a4paper, 12pt, parskip]{scrreprt}
\usepackage{changepage}
\usepackage{calc}

\newenvironment{indentitemi}{\begin{adjustwidth}{\labelwidth-\widthof{\labelitemi}}{0pt}}{\end{adjustwidth}}

\begin{document}

This is a normal text that should be left aligned.

\begin{indentitemi}
  This is another text over multiple lines that I want to have aligned equally to the bullets of the following list:
\end{indentitemi}

\begin{itemize}
  \item This is item 1.
  \item And this is a second item.
\end{itemize}

\end{document}

Two additional remarks:

• If you are using the lmodern package, you have to redefine the bullet as first-level item label. Because the latin modern font add some space left and right to the bullet. Thus the indentation still looks bad.

To get rid of that, use this modification:

\renewcommand\labelitemi{\(\vcenter{\hbox{\scriptsize\(\bullet\)}}\)}

• If you are inside a theorem-like environment like definition, the value for \labelwidth is set to zero, so it is not useable. Thats why you need an adjusted version of the indentation environment:

\newenvironment{indentitemi}{\begin{adjustwidth}{\leftmargin-\labelsep-\widthof{\labelitemi}}{0pt}}{\end{adjustwidth}}
0

Here's a solution using enumitem. It defines an alignedtext list environment in which the items are aligned with the bullets of the itemize environments, but without any labels to the items. Hence the paragraphs created with the items of an alignedtext list are just text paragraphs indented as the bullets of an itemize list.

In case it's needed, the lengths can be adjusted with the setlist commands.

\documentclass[a4paper, 12pt, parskip, headsepline]{scrreprt}
\usepackage{enumitem}

\setlist[itemize]{%
    label=\textbullet,
    leftmargin=2.5em,
    itemindent=0em,
    labelindent=1em,
    labelwidth=1em,
    labelsep=!
}
\newlist{alignedtext}{itemize}{1}
\setlist[alignedtext]{%
    label={},
    leftmargin=1.5em,
    itemindent=0em,
    labelindent=0em,
    labelwidth=0em,
    labelsep=!
}

\begin{document}
This is a normal text that should be left aligned.

\begin{alignedtext}
    \item This is another text over multiple lines that I want to have aligned equally to the bullets of the following list:
\end{alignedtext}

\begin{itemize}
    \item This is item 1.
    \item And this is a second item.
\end{itemize}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.