Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm writing a report and would like to put several questions in a \subsubsection{} with the following format (questions appear in the middle of the page)

1.2. Questions

                          *This is the question one*

This is the answer for question one.

                          *This is another question*

This is the answer for the question two.

share|improve this question
2  
Yu might want to have a look at the exercise package. –  cgnieder May 15 '12 at 12:55
    
Thanks. an example will be appreciated :-) –  asghar ashgari May 15 '12 at 12:56
4  
Please, do not only upvote good answers, but also accept those that you consider best solved your problems (in case of doubt, please see How do you accept an answer?). –  Gonzalo Medina May 15 '12 at 13:54

2 Answers 2

As cgnieder mentioned in his comment, the exercise package offers you ready to use environments and commands that could be useful for your purpose. A little example:

\documentclass{article}
\usepackage{exercise}
\usepackage{lipsum}% just to produce filler text

\renewcommand\ExerciseName{Question~}
\renewcommand\AnswerName{Answer to question}
\renewcommand\ExerciseHeader{%
  \noindent\parbox[t]{.18\textwidth}{%
    \bfseries\large\ExerciseName\ExerciseHeaderNB\hfill}%
  \parbox[t]{.72\textwidth}{%
    \centering\bfseries\large%
    \ExerciseHeaderTitle\ExerciseHeaderOrigin}%
  \par\medskip
}

\begin{document}

\section{Questions}
\begin{Exercise}[title={Some easy question}, label=que1]
\lipsum[2]
\end{Exercise}
\begin{Answer}[ref=que1]
\lipsum[2]
\end{Answer}
\begin{Exercise}[title={Some difficult question with a really really long title}, label=que2]
\lipsum[2]
\end{Exercise}
\begin{Answer}[ref=que2]
\lipsum[2]
\end{Answer}

\end{document}

enter image description here

share|improve this answer
    
Thanks for the reply. I personally do not like the "Answer to question x" part. So for now I just use : \begin{Exercise} ... \end{Exercise} for both question and its answer. –  asghar ashgari May 15 '12 at 14:11
    
I also found a problem with the solution, if the question is long it exceeds the page margins. Any solution to this? –  asghar ashgari May 15 '12 at 14:21
    
@asgharashgari all you have to do is to redefine \ExerciseHeader according to your needs; see my updated answer. –  Gonzalo Medina May 15 '12 at 14:38
    
Thanks it improved a lot. There is one main thing I can't get around it. Questions have different lengths and the 'Question' keyword is not inline with the other 'Question' keywords. How can I achieve this effect?. Thanks. –  asghar ashgari May 15 '12 at 15:04
    
@asgharashgari: please see my updated answer. Is something like that what you want? –  Gonzalo Medina May 15 '12 at 15:18

Consider the exam class. In the example below, comment or uncomment the \printanswers command to replace the ruled space for a student to write their answers with your own typeset content. No problems with questions spanning multiple pages, either.

\documentclass{exam}
\usepackage{lipsum}
%\printanswers

\begin{document}

\section{Questions}

\begin{questions}
\question[10] Why is there air?
\begin{solutionorlines}[1in]
For several reasons.
\end{solutionorlines}

\question What if there were no air?
\begin{parts}
\part[5] Describe the effect on the balloon industry.
\begin{solutionorlines}[0.5in]
Bad.
\end{solutionorlines}
\part[5] Describe the effect on the aircraft industry.
\begin{solutionorlines}[0.5in]
Worse,
\end{solutionorlines}
\end{parts}

\question[20]
\begin{parts}
\part Define the universe. Give three examples.
\part If the universe were to end, how would you know?
\begin{solutionorlines}[1in]
Something else goes here.
\end{solutionorlines}
\end{parts}

\question[60] \lipsum

\end{questions}

\end{document}

enter image description here

share|improve this answer
    
Thanks for the reply. This is not a good solution in my case; because I already have a \documentclass{} for my report and I can't change that. –  asghar ashgari May 15 '12 at 14:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.