Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I use AucTeX, which is a really great, and gigant package to edit latex (+cdlatex)

This is tangential, but have you any quick tips for someone looking to get started with AucTeX? I'm a comfortable Emacser who has started to occasionally think of some document I'd like to do in LaTeX (some maths questions for a student, or an overview of some topic). I've looked at AucTeX once or twice, and ran away thinking, oh, I'll do that some other time.

What is the order of events? Should I make a few really basic LaTeX documents first with a terminal, and then try AucTeX?



I’ve found that the best way to learn a new emacs package is incrementally: for something like Auctex, I initially just enable it for my latex documents and then I configure and learn features as I need them, never learning too much at once. Even with minimal configuration, it gives you some nice things like imenu entries for headings and a menu that surfaces some of the basic latex feature


It's pretty easy, actually. First, install the plugin, I use this with elpaca: ``` (use-package latex :ensure nil :hook (LaTeX-mode . TeX-fold-mode) ;; I don't use a lot the fold, but it's useful (LaTeX-mode . turn-on-reftex) ;; For biblatex (LaTeX-mode . LaTeX-math-mode) ;; For inserting math symbols, altough I think cdlatex is better (LaTeX-mode . outline-minor-mode) ;; If you use outline to surf throughout the buffer ;; (LaTeX-mode . abbrev-mode) ;; If you use abbrevs (LaTeX-mode . visual-line-mode) ;; Either this or auto-fill-mode, which will return when you have more than the `fill-column` characters (LateX-mode . prettify-symbols-mode) ;; Will replace most latex math symbols with unicode :bind (:map LaTeX-mode-map ("s-a" . abbrev-mode) ("s-c" . preview-clearout-at-point) ("s-q" . LaTeX-fill-buffer) ) :custom (TeX-auto-save t) (TeX-parse-self t) (preview-auto-cache-preamble nil) ;; Setting this to t should be faster, but for me it wouldn't work with lualatex (TeX-command-extra-options "-shell-escape") ;; Use pdf-tools to open PDF files (TeX-view-program-selection '((output-pdf "PDF Tools"))) ;; I use pdf-tools to read the pdf in emacs (TeX-save-query nil) ;; Auto save without saving (TeX-show-compilation nil) ;; Hide the compilation (TeX-engine 'luatex) (reftex-plug-into-AUCTeX t) ;; I think this is redundant (TeX-source-correlate-mode t) ;; To enable synctex (click on the pdf to go to source) (TeX-source-correlate-start-server t) :config (add-to-list 'TeX-command-list '("Make" "make" TeX-run-command nil t)) ;; Update PDF buffers after successful LaTeX runs (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer) )

    (use-package auctex
      :ensure  (auctex :pre-build (("./autogen.sh")
              ("./configure" "--without-texmf-dir" "--with-lispdir=.")
              ("make")))
      :demand
      :mode (("\\.tex\\'" . LaTeX-mode)
      ("\\.tex\\.erb\\'" . LaTeX-mode)
      ("\\.etx\\'" . LaTeX-mode))
      :config
      (with-eval-after-load 'preview
        (dolist (env '("tikzpicture" "circuitikz")) ;; I want to preview tikzpictures and icrcuitikz
          (add-to-list 'preview-default-preamble
         (concat "\\PreviewEnvironment{" env "}") t))
        (add-to-list 'preview-inner-environments "axis") ;; And axis (pgfplots)
        (set-face-attribute 'preview-reference-face nil
       :foreground "black"
       :background "white")))
        ;; Tikz previews look better with a white background, if you don't use it, it's way cooler to preview latex with a "trasparent" background
```

And then the usage:

Just continue using latex as you are, and then try to incorporate auctex commands. The most useful being =latex-environment= and =latex-section= + the previews. So don't write \begin{env}... nor \section{sec}, and instead use C-c C-e and C-c C-s (They seem hard, but they aren't) For the previews, use C-c C-p ... (there are a lot of options there, using which-key you can see them) And for compiling use C-c C-c. I recommend reading https://karthinks.com/software/latex-input-for-impatient-sch... and if you have the time, read bits of the manual

(Sorry, I can't get the code to display right. goto https://gitlab.com/vslavkin/emacs-config/-/blob/master/emacs... and search for the latex heading)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: