3

I want to achieve something like this,

1. Question One             The answer to the question.

2. Question Two             The answer to the question
                            that can span across multiple
                            lines because it is long.

3. Sometimes the question   Only one line answer
   can span across multi-
   ple line but have one
   answer.

4. Sometimes the question   The answers can also have
   can have multiple        multiple lines and one thing
   lines.                   notice is that there is
                            enumeration as well.

I tried multicol, tabbing, multienum environment but can't do this.

5
  • 2
    A table with three columns?
    – Thruston
    Jun 20, 2016 at 10:19
  • Should the question and answer columns be equally wide?
    – Mico
    Jun 20, 2016 at 10:25
  • What is the other column for? I need two columns. And tables will float. I don't don't want it to. And no, the question column is shorter than the answer column.
    – sigsegv
    Jun 20, 2016 at 10:26
  • A first col for the numbers
    – Thruston
    Jun 20, 2016 at 10:27
  • And I meant a tabular not a table environment. tabulars don't float.
    – Thruston
    Jun 20, 2016 at 10:27

1 Answer 1

2

A suggestion with automatic question counting at the beginning of the first column.

\documentclass{article}

\newcounter{questioncnt}

\usepackage{array}

\newcolumntype{N}[1]{>{\raggedleft\stepcounter{questioncnt}\thequestioncnt.\arraybackslash}m{#1}}

\usepackage{blindtext}

\begin{document}

\begin{tabular}{N{2cm}p{5cm}p{6cm}}
  & \blindtext & \blindtext \tabularnewline
  & \blindtext & \blindtext \tabularnewline
\end{tabular}

\end{document}

Another example:

\documentclass{article}

\newcounter{questioncnt}
\usepackage{array}

\newcolumntype{N}[1]{>{\raggedleft\stepcounter{questioncnt}\thequestioncnt.\arraybackslash}R{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\usepackage{blindtext}

\begin{document}


\begin{tabular}{N{2cm}L{6cm}L{6cm}}
  & What is the meaning of life? & foo \tabularnewline
  & What is the answer to any question in the universe? & Of course, there is only one answer and the answer can only be \huge 42 \tabularnewline
\end{tabular}

\end{document}
5
  • Nice! And can you add ragged right to the text columns easily? With the OP text you get overfull boxes with such narrow widths.
    – Thruston
    Jun 20, 2016 at 10:29
  • This is what I want. But, can this be done by avoiding counters and using enumerate instead?
    – sigsegv
    Jun 20, 2016 at 10:33
  • @Ayatana: No, enumerate is not very useful here, in my point of view. By the way, enumerate uses counters too ;-)
    – user31729
    Jun 20, 2016 at 10:39
  • Sorry, can you modify you code to accept newline that stay in the same column. `\\` starts a new row in the table.
    – sigsegv
    Jun 20, 2016 at 10:43
  • @Ayatana: Use \newline instead of `\`
    – user31729
    Jun 20, 2016 at 10:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .