[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX-devel] exam class, automatically labels and refs

From: Uwe Brauer
Subject: Re: [AUCTeX-devel] exam class, automatically labels and refs
Date: Sun, 14 Jun 2015 22:03:29 +0200
User-agent: Gnus/5.13001 (Ma Gnus v0.10) XEmacs/21.5-b34 (linux)

   > Uwe Brauer <address@hidden> writes:

   > Ah, ok.  Then write a style file for exam and define as last argument
   > definition of the \question macro `reftex-label'.

   >   (TeX-add-symbols '("question" "Title" ["Points"] reftex-label))

I Ā«solvedĀ» my problem by using the following code which I found in the
(defun detect-question (bound)
  (let ((cnt 0))
    (catch 'exit
          ;; Search backward for all possible delimiters
           (concat "\\(^[ \t]*\n\\)\\|\\(\\\\question\\.\\)\\|"
           nil t)
        ;; Check which delimiter was matched.
         ((match-beginning 1)
          ;; empty line terminates all - return nil
          (throw 'exit nil))
         ((match-beginning 2)
          ;; \z. terminates one list level - decrease nesting count
          (decf cnt))
         ((match-beginning 3)
          ;; \ex. : return match unless there was a \z. on this level
          (throw 'exit (if (>= cnt 0) (match-beginning 3) nil)))
         ((match-beginning 4)
          ;; \a. : return match when on level 0, otherwise
          ;;       increment nesting count
          (if (>= cnt 0)
              (throw 'exit (match-beginning 4))
            (incf cnt))))))))             

(detect-question ?q "question:%f" "~\\ref{%s}" nil ("question"))

This code is a completely overkill and I have to debug it to see, what I
can delete but right now it works.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]