About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-12-13: Ebook sale (12th December 2024 – 1st January 2025): cybercrime fiction short stories Unsocial Media and Smile for the Camera free; crime fiction short story The Briefcase free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99.

Exercise 3: Iterating Through a List (Solution)

This is a solution to Exercise 3.
% arara: pdflatex
\documentclass[captions=tableabove]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{datatool}

\begin{document}

\newcommand*{\mylistI}{A,B,C,D}
\newcommand*{\mylistII}{a,b,c,d}

\renewcommand*{\do}[1]{& #1}

\begin{tabular}{lcccc}
\bfseries List 1: 
\expandafter\docsvlist\expandafter{\mylistI}\\
\bfseries List 2: 
\expandafter\docsvlist\expandafter{\mylistII}
\end{tabular}

Make third item empty.

\renewcommand*{\mylistII}{a,b,,d}

\begin{tabular}{lcccc}
\bfseries List 1: 
\expandafter\docsvlist\expandafter{\mylistI}\\
\bfseries List 2: 
\expandafter\docsvlist\expandafter{\mylistII}
\end{tabular}

\newcommand*{\missingdata}{}
\renewcommand*{\mylistII}{a,b,\missingdata,d}

Make third item \verb|\missingdata|.

\begin{tabular}{lcccc}
\bfseries List 1: 
\expandafter\docsvlist\expandafter{\mylistI}\\
\bfseries List 2: 
\expandafter\docsvlist\expandafter{\mylistII}
\end{tabular}

\end{document}

Download docsvlist.tex or docsvlist.pdf.

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs