make latex honor newlines
-
18-12-2020 - |
Question
Is there an environment in LaTeX to accomplish this?
Feb 22 06:00AM - Wake up
Feb 22 06:15AM - Have breakfast
Feb 22 08:00AM - A very long sentence that I will have to break at some point
but maintaining indentation
Feb 22 08:00AM - Or maybe just a list here
One
Two
Three
Verbatim is not what I want, and finishing every sentence with \\ does not honor indentation. Is there an easy way to accomplish this, or will I have to manually tweak it?
Solution
I suggest using the tabularx
package. This will let LaTeX automatically break long lines, unlike the ordinary tabular
environment.
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\columnwidth}{rX}
Feb 22 06:00AM -& Wake up \\
Feb 22 06:15AM -& Have breakfast \\
Feb 22 08:00AM -& A very long sentence that I will have to break at some point
but maintaining indentation \\
Feb 22 08:00AM -& Or maybe just a list here
One
Two
Three
\end{tabularx}
\end{document}
If you want to put manual breaks in, that's easy:
Feb 22 08:00AM -& Or maybe just a list here \\
& One \\
& Two \\
& Three
More information:
- LaTeX documentation (I found this using the Visual LaTeX FAQ)
- TeX FAQ entry Fixed-width tables
OTHER TIPS
OK the best way that I have found so far is to use org-mode (since this is how I'm generating LaTeX in the 1st place) and use an orgmode table.
| Feb 22 06:00AM - | Wake up |
| Feb 22 06:15AM - | Have breakfast |
| Feb 22 08:00AM - | A very long sentence that I will have to break at some point but maintaining indentation |
| | Or maybe just a list here |
| | One |
| | Two |
| | Three |
Then it will get exported as a tabulated environment, like so:
\begin{tabular}{ll}
Feb 22 06:00AM - & Wake up \\
Feb 22 06:15AM - & Have breakfast \\
Feb 22 08:00AM - & A very long sentence that I will have to break at some point but maintaining indentation \\
& Or maybe just a list here \\
& One \\
& Two \\
& Three \\
\end{tabular}
Just set parindent to a negative value, and let each item be a paragraph:
\documentclass{article}
\parindent -4em
\begin{document}
Feb 22 06:00AM - Wake up
Feb 22 06:15AM - Have breakfast
Feb 22 08:00AM - A very long sentence that I will have to break at some point but maintaining indentation
Feb 22 08:00AM - Or maybe just a list here\\
One\\
Two\\
Three\\
\end{document}
Maybe I misunderstood your question in my previous answer. If you want the the amont of indentation to be automatically adjusted to the longest label, use itemize:
\documentclass{article}
\begin{document}
\begin{itemize}
\item[Feb 22 06:00AM -] Wake up
\item[Feb 22 06:15AM -] Have breakfast
\item[Feb 22 08:00AM -] A very long sentence that I will have to break at some point but maintaining indentation
\item[Feb 22 08:00AM -] Or maybe just a list here\\
One\\
Two\\
Three\\
\end{itemize}
\end{document}