3

I'm attempting to write program documentation for some recent software that I am in the process of developing and I'm currently using the tabular environment to format a changelog as to dates when certain development milestones were achieved.

The issue I'm running into is that I would like the second column in a row (the actual notes as to what the milestone was) to word-wrap, changing the height of the row rather than running off the page, as seems to be the default behavior:

tabular issue

I found this answer that describes a similar fix, but I'd be interested in seeing if there was a more "native" solution; I doubt my eye-judgment breaks would appear better than the behavior of an actual word-wrap function.

Here is the minimal non-working example:

\documentclass  [imperial,twoside,8pt]  {octavo}

\usepackage [defaultsans]   {cantarell}
\usepackage [T1]            {fontenc}
\usepackage [svgnames,table]{xcolor}
\usepackage                 {tikz}
\usepackage                 {bytefield}
\usepackage                 {listings}
\usepackage                 {glossaries}
\usepackage                 {tcolorbox}
\usepackage                 {etoolbox}
\usepackage                 {geometry}
\usepackage                 {array}
\usepackage                 {colortbl}
\tcbuselibrary              {breakable}

% ----- COMMANDS ----- %

\geometry{
    paperwidth=20.995cm,    
    paperheight=27.94cm,    
    vmargin=1.5cm,      
    inner=1.5cm,        
    outer=2.29cm,       
    bindingoffset=0.89cm 
}

\renewcommand{\familydefault}{\sfdefault}

\definecolor{pantone300c}   {RGB}   {0, 94, 184}    % Blue   - Pantone 300C
\definecolor{pantone3005u}  {RGB}   {0, 120, 191}   % Blue   - Pantone 3005U
\definecolor{pantone2035u}  {RGB}   {222, 67, 67}   % Red    - Pantone 2035U
\definecolor{pantonemedyel} {RGB}   {255, 225, 0}   % Yellow - Pantone Medium

\newcommand* {\arraycolor}[1]   {\protect\leavevmode\color{#1}}
\newcolumntype{D}       {>{\columncolor{Gray!42}}c}
\newcolumntype{X}       {>{\columncolor{pantone300c!50!white}}c}

\newcommand{\textscbf}[1]{\bfseries\scshape #1}

% ----- END COMMANDS ----- %

\begin{document}

\graphicspath{ {images/} }

\begin{center}
    \sffamily
    \arrayrulecolor{white}
    \arrayrulewidth=1pt
    \renewcommand{\arraystretch}{1.5}
    \rowcolors[\hline]{3}{.!50!White}{}
    \begin{tabular}{X|X}
        \multicolumn{2}{D}{\textscbf{Relevant Dates of Program Development}} \\
        \rowcolor{.!50!Black}
        \arraycolor{White} \textscbf{Date} &
        \arraycolor{White} \textscbf{Notes} \\
        % ----- ARRAY STARTS HERE ----- %
        \textbf{31 May 2016} & Work on \texttt{MainForm} UI logic, behavior, and event handlers begun. General layout and topology of program from a UI perspective worked out. \\
        % ----- ARRAY ENDS HERE ----- %
    \end{tabular}
\end{center}

\clearpage

\end{document}

I've seen before in more bare tables where one can specify the column width directly during the environment construction, but I'm not too sure how that approach would fare with the customized table layout that I've created. Any advice?

4

Your X columns are useless: they're enhanced versions of c in a plain tabular environment. Load tabularx ( which defines its own X column type), remove your definition of the X column type, and use

\begin{tabularx}{\linewidth}{>{\columncolor{pantone300c!50!white}}X|>{\columncolor{pantone300c!50!white}}X} 
  …
\end{tabularx}
  • 1
    This worked great; I had to sniff out the error caused by \begin{tabularx] (mismatched brace, couldn't edit as not 6 characters). – ecfedele Jun 18 '16 at 4:20
  • Oh! Sorry, I didn't check. Thanks for pointing the typo! I've fixed it. – Bernard Jun 18 '16 at 9:47

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.