Malabarba / latex-extra

A series of usability improvements for Emacs latex-mode.
GNU General Public License v3.0
69 stars 14 forks source link

Using facilities of latex-extra with exam documentclass #33

Open mandarm opened 3 years ago

mandarm commented 3 years ago

The exam documentclass provides a questions environment, which comprises one or more \question s. Each question can have parts, subparts, etc. A skeleton might look like:

\begin{questions}

\question[2] What is foo? That 2 in square brackets denotes the marks for this question.
  \begin{choices}
  \choice bar
  \choice baz
  \end{choices}

\question (\totalpoints{} marks)
  Blah blah
  \begin{parts}
  \part[1] This is a difficult question worth 1 point.

    \begin{oneparchoices}
    \choice TRUE
    \choice FALSE
    \end{oneparchoices}

  \part[2] How many points is this question with 4 alternatives worth?
    \begin{choices}
    \choice 1
    \choice 2
    \choice 3
    \choice 4
    \end{choices}

I've been trying to modify latex/section-hierarchy to take care of the above. I tried

     (setq latex/section-hierarchy
           (append '("\\\\\\(checkbox\\|choice\\)\\_>"
                     "\\\\\\(begin\\|end\\){\\(onepar\\)?\\(checkbox\\|choic\\)es}"
                     "\\\\subsubpart\\(\\[[0-9]+\\]\\)?"
                     "\\\\\\(begin\\|end\\){subsubparts}"
                     "\\\\subpart\\(\\[[0-9]+\\]\\)?"
                     "\\\\\\(begin\\|end\\){subparts}"
                     "\\\\part\\(\\[[0-9]+\\]\\)?"
                     "\\\\\\(begin\\|end\\){parts}"
                     "\\\\question\\(\\[[0-9]+\\]\\)?"
                     "\\\\\\(begin\\|end\\){questions}")
                   (remove "\\\\part\\*?\\_>" latex/section-hierarchy))))

C-cC-n and C-cC-p takes me forward and backward across questions as expected, but I can't get things to work with parts, choices, etc. If you could please tell me what I'm doing wrong, that would be great!