0

I'm trying to typeset a sideways table with automatic numbering down the rows and sub-numbering across the columns. I used this answer to number the rows but that only gets me the row header numbers. I'd like the columns to have corresponding sub-numbers to each row (e.g. 1. row header 1a. approximately two rows of..., 1b. ..., 1c. ...). The MWE retains some of the required formatting as my document so some elements (such as the table being sideways) may not be necessary. My attempts have resulted in the counting continuing across the rows rather than getting sub-numbers (e.g. I get 1. 2. 3. 4. across the first row and then the second row starts at 5.) I'm new to LaTeX and this is my first post so sorry if this is obvious or if I've missed the answer elsewhere.

MWE:

\documentclass[11pt,a4paper,openright,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{rotating}

\renewcommand{\arraystretch}{1.5}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcounter{rowcount}
\setcounter{rowcount}{0}

\begin{document}
\begin{sidewaystable}
\centering
\caption{An Appropriate Table Title}
\small
\label{tab:valued_language_capabilities}
\begin{tabular}{@{\stepcounter{rowcount}\therowcount.\hspace*{\tabcolsep}}L{40mm}L{45mm}L{45mm}L{45mm}}
\multicolumn{1}{>{\makebox[3em][r]{}}l}{}   & column header & column header & column header\\
\hline
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
\hline
\end{tabular}
\end{sidewaystable}
\end{document}

Compiles as:

Numbered rows but no sub-numbers across the row in each column

1 Answers1

1

Like this? (I used \hskip just to reduce the number of letters.)

\documentclass[11pt,a4paper,openright,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{rotating}

\renewcommand{\arraystretch}{1.5}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcounter{rowcount}
\setcounter{rowcount}{0}
\newcounter{colcount}[rowcount]% auto reset
\renewcommand{\thecolcount}{\therowcount\alph{colcount}}

\begin{document}
\begin{sidewaystable}
\centering
\caption{An Appropriate Table Title}
\small
\label{tab:valued_language_capabilities}
\begin{tabular}{@{\stepcounter{rowcount}\therowcount.\hskip\tabcolsep}L{40mm}
  @{\hskip\tabcolsep\stepcounter{colcount}\thecolcount\hskip\tabcolsep}L{45mm}
  @{\hskip\tabcolsep\stepcounter{colcount}\thecolcount\hskip\tabcolsep}L{45mm}
  @{\hskip\tabcolsep\stepcounter{colcount}\thecolcount\hskip\tabcolsep}L{45mm}}
\multicolumn{1}{>{\makebox[3em][r]{}}l}{}   & column header & column header & column header\\
\hline
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
row header  & approximately two lines of row subcontent & approximately two lines of row subcontent & approximately two lines of row subcontent\\
\hline
\end{tabular}
\end{sidewaystable}
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Yep. That works nicely. I removed the sub-numbering from the first column though since I only needed a 1a. in the second column, 1b. in the third column, and 1c. in the fourth column. The first column is a category label so just needs a 1. – Danny Foster Mar 22 '20 at 04:31
  • Right! Two @s don't make since anyway. – John Kormylo Mar 22 '20 at 15:35
  • I also needed \multicolumn{1}{>{\makebox[3em][r]{}}l}{column header} to clean up the first table row for a perfect solution. – Danny Foster Mar 22 '20 at 20:26