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.

There a some math problems& answers, I want to show them in two columns as following: enter image description here

But I have no idea how to implement this function.

I have tried tabular and multicols, however these commands didn't work as I expected.

Any help would be appreciated!

share|improve this question
4  
Can you please post what you have tried so far? –  Harish Kumar Dec 9 '12 at 12:20
    
It depends on the class you are using but with the basic article class, the twocolumn option (hence \documentclass[twocolumn]{article} in your preamble) may help, unless you are trying to achieve something different.. –  Corentin Dec 9 '12 at 12:24
    
A (long)table containing parboxes would probably the easiest and most flexible approach. –  Stephan Lehmke Dec 9 '12 at 15:21
add comment

1 Answer

up vote 3 down vote accepted

I believe this might work. We put two minipages on a line, the code is different from left(=odd, we start a paragraph there) and right(=even, we make a horizontal space before and vertical space after) Q&A

I hope that the usage is clear. We added \raggedbottom to allow the pages to be underfull.

enter image description here

\documentclass{article}

\raggedbottom

\newcounter{QA}
\newcommand\QA[2]{
  \refstepcounter{QA}
  \ifodd\arabic{QA}
    \par\noindent\begin{minipage}[t]{0.47\textwidth}
  \else
    \hspace{0.06\textwidth}\begin{minipage}[t]{0.47\textwidth}
  \fi
  \textsf{\bfseries Q\arabic{QA}:}\hspace{0.3em plus 0.2em minus 0.1em}\ignorespaces#1
  \smallskip\par
  \textsf{\bfseries A\arabic{QA}:}\hspace{0.3em plus 0.2em minus 0.1em}\ignorespaces#2
  \ifodd\arabic{QA}
    \end{minipage}\ignorespaces
  \else
    \hspace{0.06\textwidth}\end{minipage}
    \bigskip\par
  \fi
}

\begin{document}

\QA{
  Why $42$?
  }{
  Because $42=\int_0^{42}1 dx$.
  Because $42=\int_0^{42}1 dx$.
  Because $42=\int_0^{42}1 dx$.
  Because $42=\int_0^{42}1 dx$.
  Because $42=\int_0^{42}1 dx$.
  Because $42=\int_0^{42}1 dx$.
}
%
\QA{
  Why $43$?
  }{
  Because it is a prime number.
}
%
\QA{
Why $44$?
}{
Because it is a palindrome.
}

\end{document}
share|improve this answer
add comment

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.