1

Consider a document in which there are a few sections containing lists. The content is predictable; the list is preceded by a tiny preamble. Something like this:

\documentclass{article}%

% BASIC QUALIFICATIONS

\def\qualificationa{A degree}%
\def\qualificationb{Skill}%
\def\qualificationc{Common sense}%
%\def\qualificationd{Enthusiasm}%

\begin{document}

% duties
\section*{Basic Qualifications}

The successful candidate will have the following basic qualifications:

\begin{itemize}
\item{\qualificationa}%
\item{\qualificationb}%
\item{\qualificationc}%
%\item{\qualificationd}%
\end{itemize}

\end{document}

This mwe is inefficient and kind of useless for obvious reasons: (1) the use of definitions does not reduce the size or complexity of the code (2) one has to manage the a, b, etc. suffixes.

The following pseudocode would address both of these points

\documentclass{article}%

% BASIC QUALIFICATIONS

% define an array called \qualifications which has the elements:
% A degree
% Skill
% Common sense
% Enthusiasm

\begin{document}

% duties
\section*{Basic Qualifications}

The successful candidate will have the following basic qualifications:

\begin{itemize}
% for all elements in the array, wrap the value of the array element at index defined by the for loop counter with `\item{` and `}`
\end{itemize}

\end{document}
1

Such list processing capabilities are provided by etoolbox:

enter image description here

\documentclass{article}

\usepackage{etoolbox}

% BASIC QUALIFICATIONS
\listadd\qualifications{A degree}%
\listadd\qualifications{Skill}%
\listadd\qualifications{Common sense}%
\listadd\qualifications{Enthusiasm}%

\begin{document}

% duties
\section*{Basic Qualifications}

The successful candidate will have the following basic qualifications:

\begin{itemize}
  \forlistloop{\item}{\qualifications}
\end{itemize}

\end{document}
1
  • Grateful for this suggestion. This solution solves each of the issues identified in the original question. – John Chris May 26 '20 at 6:25

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.