# Forum: support

Monitor Forum | Start New ThreadRE: math mode in multiple choice questions [ reply ] By: michael schulte on 2017-05-23 13:16 | [forum:45148] |

Thanks Achim - this: \begin{question} Question \begin{answerlist} \item $0 \leq p(E) \leq 1$ \item $1 \leq p(E) \leq 100$ \item $p(S) = 100$ \item $p(S) = 1$ \item $p(A | B) = p(A) + p(B)$ \end{answerlist} \end{question} works :) PS: I have a feeling that we have been here ... |

RE: math mode in multiple choice questions [ reply ] By: Achim Zeileis on 2017-05-23 11:18 | [forum:45146] |

The number of backslashes you need depends on how you include your "question" vector in the {question} environment. If you use \Sexpr{}, you need four (!) backslashes to escape a single backslash, but if you use answerlist() you just need two backslashes. The reason for the four backslashes in case of \Sexpr{} is that the code chunk is read first and then written through \Sexpr{}. The backslash has to be escaped in both instances, i.e., \\\\leq becomes \\leq after reading and \leq after writing. However, if answerlist() inside a <<>>= ... @ code chunk is used then only normal escaping via \\leq is necessary. Moreover, in this question with static items the whole issue can be avoided by writing the {answerlist} directly into the {question}, i.e., \begin{answerlist} \item $0 \leq p(E) \leq 1$ \item $1 \leq p(E) \leq 100$ \item $p(S) = 100$ \item $p(S) = 1$ \item $p(A | B) = p(A) + p(B)$ \end{answerlist} |

math mode in multiple choice questions [ reply ] By: michael schulte on 2017-05-23 09:42 | [forum:45144] |

hi, I want to build a multiple choice question (with 5 options) with some formulas: I tried this: questions[1]<-'$$0 \leq p(E) \leq 1$$' questions[2]<-'$$1 \leq p(E) \leq 100$$' questions[3]<-'$$p(S) = 100$$' questions[4]<-'$$p(S) = 1$$' questions[5]<-'$$p(A | B) = p(A) + p(B)$$' and many other ways to escape the \ ... what I get is: Error: chunk 2 Error : '\l' is an unrecognized escape in character string starting "'$$0 \l" any hints how this could be done? thanks michael |