[OS X TeX] FAQ List Structure?

Michael Sharpe msharpe at ucsd.edu
Thu Oct 13 18:10:11 EDT 2011


On Oct 13, 2011, at 1:45 PM, David Craig wrote:

> I need to create a FAQ-type document with a list of groups of questions linked to answers below (in the same document).    The question groups and questions need to be numbered.  Among other things, this means that the numbering in the list of questions needs to match the numbering in the answers, but the complete list of questions needs to PRECEED the complete list of answers.     It would be nice if the tex code could be such that the questions and answers could be entered together but typeset separately, something like a description environment but pairing the list of questions with a list of the questions/answers following:
> 
> \begin{FAQ}
> \faqheading{here's heading 1}
> \faqitem{Here's question 1a}{Here's answer to 1a}
> \faqitem{Here's question 1b}{Here's answer to 1b}
> \faqheading{here's heading 2}
> \faqitem{Here's question 2a}{Here's answer to 2a}
> ...
> \end{FAQ}
> 
> which typesets as
> 
> Heading 1
> Q1a
>  A1a
> Q1b
>  A1b
> Heading 2
> Q2a
>  A2a
> 
> (and so on).   Option for choosing numbering scheme would be nice, but perhaps not essential.    Obviously, one would want to use hyperref to link questions to answers, and ideally, answer environment could have a automatic link back to the list of questions i.e. a boilerplate "Back to top" link after each answer.
> 
> I have thought of several ways to accomplish this, but they are all very kludgy indeed, given my skills.   I'm open to suggestions.   I haven't found any packages that, as far as I can tell, provide this kind of clean paired-list type of environment.
> 

Perhaps the enumitem and pgffor packages might be useful. As a simple example: (note that commas separate the list items, and commas embedded in the items must be protected by embedding the entire list item in braces)

\usepackage{enumitem}
\usepackage{pgffor}
\begin{document}
\noindent List heading 1:
\begin{enumerate}
\foreach \qu / \ans in {{Question 1}/{Answer 1},Question 2/Answer 2}
{\item \qu. \ans}
\end{enumerate}
List heading 2:
\begin{enumerate}[resume]
\foreach \qu / \ans in {{Question 3}/{Answer 3},Question 4/Answer 4}
{\item \qu. \ans}
\end{enumerate}
\end{document}  

Michael


More information about the MacOSX-TeX mailing list