0

I am currently trying to simplify the process of creating commented ordered and unordered lists in LaTeX. I have a method that achieves the desired visual result, but the syntax seems overly complex. I'm wondering if there's a cleaner or more straightforward approach.

Here's my current implementation:

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}

\section{Example A}

\hspace{\parindent} \noindent\begin{tabularx}{\textwidth}{@{}l@{\hspace{0.5cm}}lX}
    \textbullet & First Statement  & \# First Comment  \\ \addlinespace
    \textbullet & Second Statement & \# Second Comment \\ \addlinespace
    \textbullet & Third Statement  & \# Third Comment  \\ \addlinespace
\end{tabularx} \hspace{-\parindent}

This is some commentary on the list.

\section{Example B}

\hspace{\parindent} \noindent\begin{tabularx}{\textwidth}{@{}l@{\hspace{0.5cm}}lX}
    1. & First Statement  & \# First Comment  \\ \addlinespace
    2. & Second Statement & \# Second Comment \\ \addlinespace
    3. & Third Statement  & \# Third Comment  \\ \addlinespace
\end{tabularx} \hspace{-\parindent}

This is some commentary on the list.

\end{document}

I attempted to simplify this by creating new commands for the beginning and end of the list, but encountered issues with closing the list:

\newcommand{\beginCommentList}{
    \hspace{\parindent} \noindent\begin{tabularx}{\textwidth}{@{}l@{\hspace{0.5cm}}lX}}
    
\newcommand{\closeCommentList}{
    \end{tabularx} \hspace{-\parindent}}

Ideally, I'd like to find a solution that allows for a simpler syntax, such as:

\documentclass{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{tabularx}
\usepackage{booktabs}

% Define CommentItemize
% Define CommentEnumerate

\begin{document}

\section{Example A}

\begin{CommentItemize}
    First Statement  & First Comment
    Second Statement & Second Comment
    Third Statement  & Third Comment
\end{CommentItemize}

This is some commentary on the list.

\section{Example B}

\begin{CommentEnumerate}
    First Statement  & First Comment
    Second Statement & Second Comment
    Third Statement  & Third Comment
\end{CommentEnumerate}

This is some commentary on the list.

\end{document}

Any suggestions or feedback on how to achieve this would be greatly appreciated. Thank you in advance for your help!

2
  • \hspace{\parindent} \noindent is this intended? the \noindent does nothing here so this forces an indent of 2 \parindent + 1 word space. May 16 at 22:11
  • "but encountered issues with closing the list:" see the tabularx manual, you need \tabularx and \endtabularx not \begin{tabularx} (and \newenvironment) May 16 at 22:13

1 Answer 1

1

Coerce a list in a table column could be a bad idea. You can use the normal itemize or enumerate environments but instead of the standard \item Statement use a macro as \foo{Statement}{Comment}. The advantage is that in the same list you can still use just \item Statement when the comment is not needed at all in some row, or type some like \foo[30]{Statement}{Comment}if you want limit some item to only the 30% of the width to include a very long comment without affect to the whole list.

enter image description here

\documentclass{article}
\usepackage{lipsum,xcolor}
\newcommand\foo[3][5]{\item\parbox[t]{.#1\linewidth}{#2}\hfill\parbox[t]{\dimexpr.95\linewidth-0.#1\linewidth}{\color{olive}\sffamily {\bfseries\#} #3}}

\begin{document}

\begin{enumerate}

\foo {First Statement} {First Comment}  

\foo {Second Statement} {Second Comment}  

\foo {Third Statement} {Third Comment}  

\foo {\lipsum[1][1-2]} {\lipsum[2][1]}  

\foo {\lipsum[6][1-2]} {\lipsum[7][1]}  

\foo[20] {\lipsum[1][1]} {\lipsum[2][1-3]}   

\foo[70] {\lipsum[1][1-6]} {\lipsum[2][1]}  

\end{enumerate}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .