# Multiple lines of text inside brackets?

I'm new to the TeX StackExchange. I've been working with the sorted list function I found here (Alphabetically display the items in itemize), and I came across an issue that I spent hours looking for online but I couldn't find. I also couldn't quite comment on this person's post (not enough reputation points), and I realized that this issue is completely possible out of this context.

The items in my sortedlist are quite long:

 \documentclass{article}
\usepackage{datatool}
\newcommand{\sortitem}[1]{%
\DTLnewrow{list}% Create a new entry
}
\newenvironment{sortedlist}{%
\DTLifdbexists{list}{\DTLcleardb{list}}{\DTLnewdb{list}}% Create
}{%
\DTLsort{description}{list}% Sort list
\begin{itemize}%
\DTLforeach*{list}{\theDesc=description}{%
\item \text{\theDesc}}% Print each item
\end{itemize}%
}

\begin{document}
\section{section1}
All lists of readings and references are in alphabetical order.
\begin{sortedlist}
\sortitem{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt \\ ut labore et dolore magna aliqua. Ut enim ad minim veniam Lorem ipsum dolor sit amet,  consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam}
\sortitem{quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat \\ quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat}
\sortitem{Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu \\ fugiat nulla pariatur Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur}
\end{sortedlist}
\end{document}


I purposefully cut the line at an earlier spot, to test if the line would cut in the first place. The text just continues off the page, even with the line breaks. It looks like this:

Is there any code that I could put in the sortedlist or sorteditem definition to ensure that this doesn't happen? Or am I doing the line breaks incorrectly?

• Your sortedlist prints like this, with all items being sorted together with the appropriate line-breaks. You must be doing something odd. Please provide a minimal example that replicates your problematic behaviour. It should start with \documentclass and end with \end{document} and allow the community to copy-and-paste-and-compile the code and see exactly what the issue is in the output. – Werner Jan 6 '18 at 1:34
• Edited! Do you mind looking at it again? – Anon E. Muss Jan 6 '18 at 2:12

The answer you link to prints every element in the sorted list using

\item \theDesc


\item \text{\theDesc}


from amsmath (loaded by datatool). Replace this with the original definition:

\documentclass{article}
\usepackage{datatool}
\newcommand{\sortitem}[1]{%
\DTLnewrow{list}% Create a new entry
}
\newenvironment{sortedlist}{%
\DTLifdbexists{list}{\DTLcleardb{list}}{\DTLnewdb{list}}% Create
}{%
\DTLsort{description}{list}% Sort list
\begin{itemize}%
\DTLforeach*{list}{\theDesc=description}{%
\item \theDesc}% Print each item
\end{itemize}%
}

\begin{document}

\section{section1}