auctex-devel
[Top][All Lists]
Advanced

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

Re: [AUCTeX-devel] [problems with TeX-arg-ref]


From: Uwe Brauer
Subject: Re: [AUCTeX-devel] [problems with TeX-arg-ref]
Date: Wed, 16 Nov 2016 17:20:02 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

   > Hi Uwe,
   > Uwe Brauer <address@hidden> writes:


   > I'm not sure if I understand this correctly, but I see a point here:
   > `TeX-arg-ref' inserts an empty pair of braces when the argument is
   > empty.


   > It is `LaTeX-label' (ah! ;-) which behaves almost exactly as
   > `reftex-label'.  You could write a function like this:

   >     (defun LaTeX-exam-label (_optional &optional name type)
   >       "Indent the line and query/insert a label incl. the \"\\label\" 
macro.
   >     Arguments NAME and TYPE are the same as for the function
   >     `LaTeX-label'.  OPTIONAL is ignored."
   >       (indent-according-to-mode)
   >       (let ((currenv (LaTeX-current-environment)))
   >         (LaTeX-label (or name currenv) type)))

   > And then:

   >    (TeX-add-symbols
   >     '("titledquestion" "Title" ["Points"] LaTeX-exam-label 
(TeX-arg-literal " "))


Thanks very much I almost finished to add all the macros, when I run
into the problem, so you are almost re conquering the crown again. I say
almost because:

   > Note that with RefTeX enabled, the job is transferred to `reftex-label',
   > otherwise `LaTeX-label' itself does it.

   > Here a small file I tested with:

   > \documentclass{exam}

   > \qformat{Question \thequestion: \thequestiontitle\dotfill\thepoints}

   > \begin{document}

   > \begin{questions}
   > \titledquestion{RefTeX is not plugged into AUCTeX}[0] When asked for a
   >   \verb|(Optional:) What label|, just hit \verb|RET| and nothing is
   >   inserted
   > \titledquestion{RefTeX is not plugged into AUCTeX}[0]\label{one} When
   >   asked for a \verb|(Optional:) What label|, enter \verb|<key>| and
   >   \verb|\label{<key>}| is inserted
   > %
   > \titledquestion{RefTeX is plugged into AUCTeX}[100] When asked for a
   >   \verb|Label: sec:|, just hit \verb|RET| and nothing is inserted
   > \titledquestion{RefTeX is plugged into AUCTeX}[100]\label{sec:reftex}
   >   When asked for a \verb|Label: sec:|, enter \verb|<label>| and
   >   \verb|\label{<sec:label>}| is inserted
   > \end{questions}

The problem is with the behavior of the last case.

IMHO, when RefTeX is plugged in, the label should be inserted
*automatically* without any prompt. That is the value of the label is
automatically calculated by RefTeX. That, at least for me, is the whole
point of RefTeX: one has not to bother and to keep track manually of the
labels used (like oops is it label number 123 or 124, don't remember
right now). [1]



That is why I proposed


(defvar exam-use-reftex nil
  "Variable which controls whether to use `reftex-label' or `TeX-arg-ref'. 
Default is to use `TeX-arg-literal'.")
; or Tex-exam-label


(if exam-use-reftex
    (defalias 'TeX-arg-literal 'reftex-label))

   > \end{document}

   > Best, Arash


Footnotes: 
[1]  frankly, without starting a flamewar, assigning labels in AUCTeX
     without RefTex is for my like using plain tex instead of LaTeX.




reply via email to

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