4

I'm looking for a method to modify my tabto-command so if the text is to long to fit in one line, the text will be tabbed again in the new line.

\documentclass[a4paper, 12pt, twosides, openany, liststotoc]{scrbook}

\usepackage{tabto}
\usepackage{lipsum}

\newcommand*{\mytab}{\tabto{4.5cm}}

\begin{document}

    \begin{itemize}
        \item One \mytab{\lipsum[4]}
        \item Two \mytab{\lipsum[4]}
    \end{itemize}

\end{document}

Thankful greetings `

1 Answer 1

2

Rather than try to do this exclusively with tabto, one could bring in a \parbox. Then you just need to know the widths involved to define the width of the \parbox.

However, this tabto method will not break items across page boundaries.

It would be preferable to dispense with the tabto and use enumitem to achieve the same thing, because it will break across page boundaries.

In the MWE below, I use the tabto method on item "One" and the enumitem method on item "Two".

\documentclass[a4paper, 12pt, twosides, openany, liststotoc]{scrbook}

\usepackage{tabto,enumitem}
\usepackage{lipsum}

\newcommand*{\mytab}[1]{\tabto{4.5cm}\parbox[t]{%
  \dimexpr\textwidth-4.5cm-\labelwidth-\labelsep}{#1}}
\begin{document}

    \begin{itemize}
        \item One \mytab{The \texttt{tabto} way  that will not
              break across page boundaries. \lipsum[4]}
        \item Two 
          \vspace{\dimexpr-\baselineskip-\parskip}
          \begin{itemize}[label=,leftmargin=4.5cm,topsep=0pt]
          \item The \texttt{enumitem} way that will break across
                page boundaries. \lipsum[4-7]
          \end{itemize}
    \end{itemize}

\lipsum[3]

\end{document}

enter image description here

enter image description here

2
  • Thanks for your response. Works absolutely fine. The prevention to break across pages is even quite good for my purpose. Thanks a lot :)
    – Psykes
    Commented Oct 24, 2017 at 10:52
  • @Psykes For completeness, I added a 2nd method to allow breaks across page boundaries. By the way, if my answer is wholly suitable to your needs, you could indicate so to the community (and me) by clicking the check mark to the left of my answer. This is called "accepting" the answer, and tells others that this approach solved your problem best (if multiple answers were provided). Commented Oct 24, 2017 at 12:47

You must log in to answer this question.

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