[texhax] FAQ environment

Matthew Leingang leingang at math.harvard.edu
Thu Jan 31 00:36:21 CET 2008


Dear Zac,

That's not too hard if you use some skip commands.  Is this what  
you're looking for?
--
\documentclass{article}
\title{FAQ}

\newenvironment{question}{%
   \bigskip\noindent\textbf{Q:}\ }
   {}

\newenvironment{answer}{%
    \medskip\noindent\textbf{A:}\ }
    {}

\begin{document}

\begin{question}
	question 1 is?
\end{question}

\begin{answer}
	answer 1.
\end{answer}

\begin{question}
	question 2 is?
\end{question}

\begin{answer}
	answer 2.
\end{answer}

\end{document}
--

The way things are defined you could either have your questions and  
answers come one after the other like they are now, or you could nest  
your answers inside the questions with the same results (but that TeX  
file might be more easily parsed by other programs). You could also  
rewrite things so that answer is only valid inside question.

Eventually you might get annoyed with the pagebreaking and try to  
coax TeX to break before a question rather than between a question  
and its answer.  That's doable by looking at the \pagebreak commands  
(although I don't know enough to test it right now).

Hope that helps!

--Matt

On Jan 30, 2008, at 6:24 AM, Zachary Leung wrote:

> Hi everyone,
>
> I'm wondering how I should define an FAQ environment. I'd like for  
> it to look something like the following:
>
> Q: question 1 is?
> A: answer 1.
>
> Q: question 2 is?
> A: answer 2.
>
> I was thinking of using a list, but how do I control the spacing so  
> that there is a small space in between Q and the A below, but there  
> is more space in between A and the Q below it?
>
> I know this is possible, but I don't know enough TeX to figure this  
> out.
>
> Thanks!
>
> Zac
>
> -- 
> Blessed is the one who finds wisdom,
>   and the one who gets understanding,
> for the gain from her is better than gain from silver
>   and her profit better than gold.
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
>
> Automated subscription management: http://tug.org/mailman/listinfo/ 
> texhax
> Human mailing list managers: postmaster at tug.org

--
Matthew Leingang
Preceptor in Mathematics
Harvard University

http://www.math.harvard.edu/~leingang/vCard.vcf





More information about the texhax mailing list