1

I'm writing a custom helper command for my beamer presentation:

\newcommand{\sectionfigure}[1]{
  \begin{tikzpicture}[overlay, remember picture]
      \node at ([shift={(0, 0.27925\paperheight)}] foot.north) {\includegraphics[height=0.37925\paperwidth]{#1}};
  \end{tikzpicture}
}

with C-c C-n and then C-c RET, AUCTeX recognizes the command, but I would like to have it asking me an image path, like it does when inserting an includegraphic macro. I placed

(TeX-add-style-hook "beamer"
            (lambda ()
              (TeX-add-symbols
               '("sectionfigure" LaTeX-arg-includegraphics))))

in my init file, but it doesn't work. I suppose AUCTeX is overwriting it when it opens the file? How can I make this effective? Thanks!

1 Answer 1

1

The usual practice for this is to source out your TeX code into a private package, say ab-beamer-addons.sty which looks like this:

\ProvidesPackage{ab-beamer-addons}

\newcommand{\sectionfigure}[1]{%
  \begin{tikzpicture}[overlay, remember picture]
    \node at ([shift={(0, 0.27925\paperheight)}] foot.north) {%
      \includegraphics[height=0.37925\paperwidth]{#1}};
  \end{tikzpicture}
}

\endinput

save the file in a directory where TeX can find it and add the following line to your .tex file:

\usepackage{ab-beamer-addons}

Then write the corresponding AUCTeX style file which looks like this:

(TeX-add-style-hook
 "ab-beamer-addons"
 (lambda ()
   (TeX-add-symbols
    '("sectionfigure" LaTeX-arg-includegraphics))

   ;; Fontification:
   (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
     (font-latex-add-keywords '(("sectionfigure" "{"))
                              'reference)))
 :latex)

Now save the lisp code above as ab-beamer-addons.el and put the file in a directory which is part of TeX-style-private (or adjust it first). Make sure you have set TeX-parse-self to t, restart Emacs and open your .tex file. Hit C-h e and check if ab-beamer-addons.el is loaded; in that case, C-c C-m sectionfigure RET should DTRT.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.