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

I want to create a multiple choice question paper and list the options horizontally. I am only looking at very simple document with horizontal list. What I want:

  1. What is 1+1?

    a) 2 b) 4 c) 3 d) 7

Is there any correct way to do it with cells other than manually using spacebars?

share|improve this question
2  
Did you have a look at Grid, Row and such? Might come in handy... –  Yves Klett Jul 17 '12 at 6:18

4 Answers 4

up vote 10 down vote accepted

To give you an idea how to go about that:

ans = {2, 4, 3, 7};

Row[Flatten[
  MapIndexed[{FromCharacterCode[#2[[1]] + 96] <> ") ", #1, 
     Spacer[20]} &, ans]]]

Mathematica graphics

or

Grid[{Flatten@
   MapIndexed[{FromCharacterCode[#2[[1]] + 96] <> ")", #1, 
      Spacer[10]} &, ans]}]

Mathematica graphics

Row and Grid behave differently regarding linewrapping, and Grid can of course be extended to 2D.

share|improve this answer
    
That is what I'm looking for. Thanks. –  Standstill Jul 17 '12 at 13:35

You could use TableForm, e.g.

TableForm[{{"a)", 2, "b)", 4, "c)", 3, "d)", 7}},
 TableSpacing -> {1, 2}]

enter image description here

share|improve this answer

You may try

Dynamic@x
Row[{"What is 1+1", Spacer[10], Control[{x, {2, 4, 7}}]}]
share|improve this answer

A list of questions and answers:

questionsAndAnswers = StringJoin /@ {"question" ~~ #[[1]], "answer" ~~ #[[1]] ~~ #[[2]], "answer" ~~ #[[1]] ~~ #[[3]], "answer" ~~ #[[1]] ~~ #[[4]], 
 "answer" ~~ #[[1]] ~~ #[[5]]} & /@ (Join @@ # & /@ 
Thread[{List /@ ToString /@ Range[5], CharacterRange["a", "d"]}, List, 1])
(*{{"question1", "answer1a", "answer1b", "answer1c", "answer1d"},
  {"question2", "answer2a", "answer2b", "answer2c", "answer2d"},
  {"question3", "answer3a", "answer3b", "answer3c", "answer3d"},
  {"question4", "answer4a", "answer4b", "answer4c", "answer4d"},
  {"question5", "answer5a", "answer5b", "answer5c", "answer5d"}} *)

Using Grid:

Column[Grid[#, Spacings -> {2, Automatic}, Alignment -> Left] & /@ 
MapIndexed[{{First@#2 , #1[[1]]},
 {"", Row[{"a)", #1[[2]], "b)", #1[[3]], "c)", #1[[4]], "d)", #1[[5]]}, Spacer[5]]}} &, questionsAndAnswers]]

enter image description here

Using StringForm:

Column[StringForm["`1` \t`2` \n\t  `3`) `4`\t `5`) `6`\t `7`) `8`\t `9`) `10`", 
Sequence @@ (Riffle[#, CharacterRange["a", "d"], {3, -1, 2}])] & /@
MapIndexed[Join @@ {#2, #1} &, questionsAndAnswers]]

enter image description here

share|improve this answer

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.