I am trying to make a macro for the rows in my table, just to make it look a bit more elegant. However, the document fails to compile when I use more than one row.
Here's the code I'm trying to duplicate:
\usepackage{tabularx}
\begin{tabularx}{\textwidth}{ r X }
\bfseries{Topic1:} & Item1, Item2, Item3 \\
\bgseries{Topic2:} & Item1, Item2, Item3 \\
\end{tabularx}
And my attempt to create a macro:
\usepackage{tabularx}
\begin{tabularx}{\textwidth}{ r X }
\newcommand{\row}[2]{\bfseries{#1:} & #2 \\}
\row{Topic1}{Item1, Item2, Item3}
\row{Topic2}{Item1, Item2, Item3}
\end{tabularx}
And the compiler error I'm getting is "Undefined control sequence." Is there any way to get this to work?
\bfseriesis incorrect.\bfseriesdoesn't take an argument and changes the font until the current group ends, so you should use as{\bfseries #1:}. Alternatively, use\textbf, which does take an argument:\textbf{#1:}. By the way, welcome to TeX.SX! – Phelype Oleinik Jun 13 '19 at 23:11