auctex
[Top][All Lists]
Advanced

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

Re: Why does a `standalone` document set `TeX-PDF-from-DVI`?


From: Arash Esbati
Subject: Re: Why does a `standalone` document set `TeX-PDF-from-DVI`?
Date: Sat, 16 Jan 2021 00:24:26 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50

Maximilian Wuttke <mwuttke97@posteo.de> writes:

> On 13/01/2021 22:48, Arash Esbati wrote:
>> AUCTeX doesn't have a style for standalone package [...]
>
> OK, so should there be a style hook for the standalone package?

Yes, it's waiting for someone to write it :-)

> It turns out that the following code already runs the style hook for
> tikz (and *not* for pstricks), since "tikz" is provided as a class
> option. (It also tries to run a style hook for "border=5pt", but there
> is none).
>
>> \documentclass[tikz,border=5pt]{standalone}
>> 
>> \begin{document}
>> 
>> \begin{tikzpicture}
>>   \node{test!};
>> \end{tikzpicture}
>> 
>> \end{document}

Actually, it doesn't run the style hook, it only loads the style file.
You can check this by eval'ing (TeX-style-list) once you load that .tex
file and/or try to get completion for tikzpicture with `C-c C-e'.

A style file standalone.el which runs the style hooks based on given
class options can look like this:

--8<---------------cut here---------------start------------->8---
(TeX-add-style-hook
 "standalone"
 (lambda ()

   (dolist (opt '("tikz" "preview" "pstricks"))
     (when (or (LaTeX-provided-class-options-member "standalone" opt)
               (LaTeX-provided-class-options-member "standalone"
                                                    (concat opt "=true")))
       (TeX-run-style-hooks opt)))

   (when (or (LaTeX-provided-class-options-member "standalone" "multi")
             (LaTeX-provided-class-options-member "standalone" "multi=true"))
     (TeX-add-symbols
      '("standaloneenv"
        (TeX-arg-eval mapconcat #'identity
                      (TeX-completing-read-multiple
                       (TeX-argument-prompt nil nil "Environment(s)")
                       (LaTeX-environment-list))
                      ","))))

   (when (or (LaTeX-provided-class-options-member "standalone" "beamer")
             (LaTeX-provided-class-options-member "standalone" "beamer=true"))
     (LaTeX-add-environments
      '("standaloneframe")))

   ;; Fontification
   (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
     (font-latex-add-keywords '(("standaloneenv" "{"))
                              'function)))
 TeX-dialect)

(defun LaTeX-standalone-class-options ()
  "Read class options for standalone document class."
  (TeX-read-key-val t `(("class"
                         ,(or LaTeX-global-class-files
                              (let ((TeX-file-extensions '("cls")))
                                (prog2
                                    (message "Searching for LaTeX classes...")
                                    (TeX-search-files-by-type 'texinputs 
'global t t)
                                  (message "Searching for LaTeX 
classes...done")))))
                        ("crop" ("true" "false"))
                        ("preview" ("true" "false"))
                        ("multi"
                         ("true" "false"
                          ,@(mapcar #'car (LaTeX-environment-list))))
                        ("varwidth"
                         ("true" "false"
                          ,@(mapcar (lambda (x)
                                      (concat TeX-esc (car x)))
                                    (LaTeX-length-list))))
                        ("border")
                        ("ignorerest" ("true" "false"))
                        ("multido" ("true" "false"))
                        ("tikz" ("true" "false"))
                        ("pstricks" ("true" "false"))
                        ("beamer" ("true" "false"))
                        ("float" ("true" "false"))
                        ("convert" ("true" "false"))
                        ("png"))))

(defun LaTeX-standalone-package-options ()
  "Read package options for standalone package."
  (TeX-read-key-val t
                    '(("subpreambles" ("true" "false"))
                      ("sort" ("true" "false"))
                      ("print" ("true" "false"))
                      ("comments" ("true" "false"))
                      ("nocomments")
                      ("group" ("true" "false"))
                      ("mode" ("tex" "image" "build"
                               "buildmissing" "buildnew"))
                      ("obeyclassoptions" ("true" "false"))
                      ("extension" (".pdf" ".eps"))
                      ("build"))))
--8<---------------cut here---------------end--------------->8---

Best, Arash



reply via email to

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