Preventing Content of Tabular Environment from Running Off the Page

column widthcolumnstablestabularxwidth

Consider the right content of the 2-column tabular environment generated by the code

    \documentclass{book}

    \begin{document}
    \thispagestyle{empty}
    \Large

    \begin{tabular}{l l} 
    January: & Some content - second column; \, Why is this running off the page? \, Victories 41, defeats 4. \\ 
    & A statement of the next line. \, Second statement. \\
    & \\
    
    February: & Some content - second column; \, would like to right-justify this column. \, Victories 41, defeats 4. \\ 
    &  A statement of the next line. \, Second statement. \\
    & \\
    
    March: & Some content - second column; \, Why is this running off the page? \, Victories 41, defeats 4. \\ 
    &  A statement of the next line. \, Second statement.
    \end{tabular}
    \end{document}

enter image description here

QUESTION: How may I prevent the run-off? More specifically, how may I automatically force line breaks when either the extent of the textwidth is reached (or at some specified width); and, with the subsequent contents of the second column justified as well?

Thank you.

Best Answer

Use tabularx:

enter image description here

\documentclass{book}

\usepackage{tabularx}
%\usepackage{showframe}% To see the page layout

\begin{document}

\thispagestyle{empty}

\Large

\noindent
\begin{tabularx}{\linewidth}{l X} 
January: & Some content - second column; Why is this running off the page? Victories 41, defeats 4. \\ 
& A statement of the next line. Second statement. \\
& \\
February: & Some content - second column; would like to right-justify this column. Victories 41, defeats 4. \\ 
&  A statement of the next line. Second statement. \\
& \\
March: & Some content - second column; Why is this running off the page? Victories 41, defeats 4. \\ 
&  A statement of the next line. Second statement.
\end{tabularx}

\end{document}

You can adjust the column separation and (for example) use @{} l X @{} as a column specification. Note that setting this inside a table will not allow for proper breaking across the page boundary (vertically).

Alternatively (and better, since page breaking is fully supported) use a list (like description):

enter image description here

\documentclass{book}

\usepackage{enumitem}
%\usepackage{showframe}% To show the document layout

\begin{document}

\thispagestyle{empty}

\Large

\begin{description}[leftmargin=5em,labelwidth=5em,labelsep=0pt,font=\mdseries]
  \item[January:] Some content - second column; Why is this running off the page? Victories 41, defeats 4. \par 
    A statement of the next line. Second statement.

  \item[February:] Some content - second column; would like to right-justify this column. Victories 41, defeats 4. \par
    A statement of the next line. Second statement.

  \item[March:] Some content - second column; Why is this running off the page? Victories 41, defeats 4. \par
    A statement of the next line. Second statement.
\end{description}

\end{document}