I'm working on a simple layout in LyX 2.2 for the exam class. Many things work very well, especially with the LatexType Item_Environment style in LyX layouts. However, I'm stuck at how to deal with the multiple-choice environment, because
\choice
\CorrectChoice
are essentially two different \item possibilities within a LatexType Item_Environment (for LyX layouts). It doesn't look possible to have two different ItemCommand definitions in LyX. Arguably, \CorrectChoice is just a special case of \choice, but it's a lot to change the Exam class...
I realized it would be much easier if \CorrectChoice were just a \choice with an optional argument set to true (or 1), e.g., \choice[1]. Perhaps there's a way to hack it back to \CorrectChoice after LyX generates the LaTeX and before the LaTeX is compiled?
I have seen some hacking things done like this with the etoolbox package, but I couldn't find anything obvious. I admit I'm not much of a TeX hacker. It would be great to know if this is possible.


\makeatletter…\makeatotherso by writing\makeatotherin the preamble you might mess things up. Also you can use theInPreamblelayout tag to move your preamble code to the layout. All together this would make a nice LyX module. – G.M. Jul 15 '16 at 13:31Preamble...PreambleEnd? I'm making those changes (testing) and will update my answer. I'm going to put the layout on github. – Fuhrmanator Jul 15 '16 at 14:42Preamble…PreambleEndas per Customization 5.3.6. – G.M. Jul 15 '16 at 15:37