[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
manual
(defun detect-question (bound)
(let ((cnt 0))
(catch 'exit
(while
;; Search backward for all possible delimiters
(re-search-backward
(concat "\\(^[ \t]*\n\\)\\|\\(\\\\question\\.\\)\\|"
"\\(\\question\\)\\|\\(\\\\question\\.\\)")
nil t)
;; Check which delimiter was matched.
(cond
((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.
Uwe