9

I would like to create a question/answer format to use on lab reports. What I would like to achieve is something like this:

a. This is the first question (in bold)?

This is the answer (it is indented and regular text).

b. This is the second question (bold)?

This is the answer (indented and regular text).

I have no idea where to start. Thank you very much for your help!

12

I would define an enumerate list and create an answer environment: consider the following:

\documentclass{article}
\usepackage{enumitem}
\newenvironment{QandA}{\begin{enumerate}[label=\bfseries\alph*.]\bfseries}
                      {\end{enumerate}}
\newenvironment{answered}{\par\normalfont}{}
\usepackage{lipsum}
\pagestyle{empty}
\begin{document}

\noindent%
\lipsum[1]
\begin{QandA}
   \item question one
         \begin{answered}
         this is my answer:  \lipsum[2]
         \end{answered}

   \item question two
         \begin{answered}
         \lipsum[3]
         \end{answered}
\end{QandA}
\lipsum[4]
\end{document}

enter image description here

This gives you some flexibility in terms of how you format the questions and how you format the answers. Notice that I kind of sledgehammer the bold font. To counteract this, I call \normalfont inside the answered environment.

The enumitem package gives you a lot of room for controlling margins.
To get further indentation on both the left and right margins, you can write

\newenvironment{QandA}{\begin{enumerate}[label=\bfseries\alph*.,leftmargin=2em,rightmargin=2em]\bfseries}
                      {\end{enumerate}}

If you want a paragraph indent at the beginning of the answer, then rewrite the answered environment to be:

\newenvironment{answered}{\setlength{\parindent}{1em}\par\normalfont}{}

If you play with these suggestions, you'll find you have a lot of control over the look and feel of the answered environment.

By adding these changes to the MWE, you'll get something like:

enter image description here

| improve this answer | |
  • Awesome! I tested this and works flawlessly!, I have another question... is there a possible way of indenting inside the answers? – Lynx Dec 29 '12 at 1:22
  • If you could explain what you mean by indenting, I'd be happy to do so. Lest you think I'm being snarky, I'm asking for clarification since within the enumerate environment paragraphs are usually already indented. – A.Ellett Dec 29 '12 at 1:33
  • Dont worry! What I mean by indenting is that the first line of every answer paragraph is indented. I know the paragraph is already indented but I was wondering if the first line can have 2 indentations. Thank you very much for the help! – Lynx Dec 29 '12 at 1:41

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.