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 am trying to create a command for a matching type of question. left column are the questions and on the right column are the choices. My problem is how will I do this, especially on the right column. How can I make a column of choices corresponding with the length of the total questions?

example output is:

enter image description here

follow up question. If inspite of writing a. choice1, is changing letter a to a small box possible?

better if could use the command like this:

  \documentclass{exam}
  \usepackage{longtable,tabu}
  \begin{document}
  \begin{mytabu}\boxedcolchoice
  \question{text text text text text}{choice1}\\
  \question{text text text text text here text here}{choice2}\\
  \end{mytabu}
  \end{document}
share|improve this question
    
You mean both columns should have same height regardless of item number or every item should be leveled with its opposite? –  percusse Dec 3 '12 at 13:20
    
yes! precisely that's what I needed. –  Kayla Dec 3 '12 at 13:21
    
Hmm, I tried to present two options. can you repeat once again for the sake of completeness which one did you confirmed? –  percusse Dec 3 '12 at 13:23
    
I mean every item should be leveled with its opposite. :) –  Kayla Dec 3 '12 at 13:29
    
In that case, you can simply use a table, no? –  recluze Dec 3 '12 at 13:35
add comment

1 Answer

Here's one possible solution using the tabu and longtable packages. The command \myquestion is in charge of typesetting the entries; it has two mandatory arguments: the first one contains the text for the question, and the second one, for the corresponding text for the choice. The row numbering and the boxes are automatically included:

\documentclass{article}
\usepackage{longtable}
\usepackage{tabu}

\newcounter{myrow}
\newcommand\mybox{%
  \raisebox{0.25ex}{\fbox{\rule{0.5em}{0pt}\rule{0pt}{0.5em}}}}
\newcommand\myquestion[2]{& #1 & & #2}

\begin{document}

\tabulinesep=3pt
\begin{longtabu} to \textwidth{
  >{\stepcounter{myrow}\themyrow.}l
  X[3]
  @{\hspace*{2em}}
  >{\mybox}l
  @{\hspace*{4pt}}X
}
\myquestion{Here's the text for the first question; and we add some text to apan more than one line.}{choice1}  \\
\myquestion{Here's the text for the second question; and we add some text to apan more than one line; and we add some text to apan more than one line; and we add some text to apan more than one line.}{choice2}  \\
\end{longtabu}

\end{document}

enter image description here

A new requirement has been made in a comment; to be able to have the longtabu width and format specification as parameters; this can be done defining a new mytabu environment with two mandatory arguments (the first one could be also defined as optional with a default value): the first argument is the width of the longtabu, and the second one, gives the format specification. The code:

\documentclass{article}
\usepackage{longtable}
\usepackage{tabu}

\newcounter{myrow}
\newcommand\mybox{%
  \raisebox{0.25ex}{\fbox{\rule{0.5em}{0pt}\rule{0pt}{0.5em}}}}
\newcommand\myquestion[2]{& #1 & & #2}
\newenvironment{mytabu}[2]
  {\tabulinesep=3pt
    \begin{longtabu} to #1{#2}
  }
  {\end{longtabu}}

\begin{document}

\begin{mytabu}{\textwidth}{
  >{\stepcounter{myrow}\themyrow.}l
  X[3]
  @{\hspace*{2em}}
  >{\mybox}l
  @{\hspace*{4pt}}X
}
\myquestion{Here's the text for the first question; and we add some text to apan more than one line.}{choice1}  \\
\myquestion{Here's the text for the second question; and we add some text to apan more than one line; and we add some text to apan more than one line; and we add some text to apan more than one line.}{choice2}  \\
\end{mytabu}

\end{document}

Now a new requirement made in an edit to the original question:

\documentclass{article}
\usepackage{longtable}
\usepackage{tabu}

\newcounter{myrow}
\newcommand\mybox{%
  \raisebox{0.25ex}{\fbox{\rule{0.5em}{0pt}\rule{0pt}{0.5em}}}}
\newcommand\myquestion[2]{& #1 & & #2}
\newenvironment{mytabu}
  {\tabulinesep=3pt
    \begin{longtabu} to \textwidth{>{\stepcounter{myrow}\themyrow.}l
  X[3]
  @{\hspace*{2em}}
  >{\mybox}l
  @{\hspace*{4pt}}X}
  }
  {\end{longtabu}}

\begin{document}

\begin{mytabu}
\myquestion{Here's the text for the first question; and we add some text to apan more than one line.}{choice1}  \\
\myquestion{Here's the text for the second question; and we add some text to apan more than one line; and we add some text to apan more than one line; and we add some text to apan more than one line.}{choice2}  \\
\end{mytabu}

\end{document}

enter image description here

share|improve this answer
    
i tried to install the tabu.sty for it is not found. But, it prompt no tlmgr found. I made to install this two but i failed for it says ubuntu version i think cant support it? i guess. So is there other way to solve my problem? –  Kayla Dec 6 '12 at 1:28
    
i encountered this kind of problem in my ubuntu and it says no way to fix it. –  Kayla Dec 6 '12 at 1:32
    
@kayla Perhaps this post can help you with your installation problem: tex.stackexchange.com/questions/73016/…. My crystal ball says you are using Ubuntu 12.04 and you are still probably using TeXLive 2009. Install TeXLive 2012 instead. If you want to install the package manually, then you can follow the directions in the link. But creating a folder texmf in your home directory and unziping the package to ~/texmf/tex/latex usually works. –  hpesoj626 Dec 8 '12 at 16:01
    
previously i tried to place my mdframed package in the home directly. I copy it so I can paste it. But what happened when is i can't paste the folder in ~/texmf/tex/latex. In short, the system doesn't allow me to do so. –  Kayla Dec 9 '12 at 9:09
1  
@kayla please see my updated answer; the third code does what you want. –  Gonzalo Medina Dec 12 '12 at 3:22
show 8 more comments

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.