emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Fwd: Is `org-preview-latex-fragment` sensitive to alignment spec


From: Nick Dokos
Subject: Re: [O] Fwd: Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
Date: Wed, 09 Apr 2014 13:22:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Rob Stewart <address@hidden> writes:

>
> I asked the question below a few days ago, about whether
> `org-preview-latex-fragment` is sensitive document class options that
> might affect alignment. I've so far not received feedback, and
> wondered whether there is more information that I could provide, or if
> my question is not interesting to other people :-)
>
> ....
>
> Is there a way to make `org-preview-latex-fragment` sensitive to LaTeX
> class options? I have a simple example to demonstrate where it does
> not:
>
> %%%%%%% #+LaTeX_CLASS: article #+LaTeX_CLASS_OPTIONS: [fleqn]
> #+LATEX_HEADER: \usepackage{amsmath}
>
> \begin{gather} b := (a \oplus s_1) \oplus s_2 \\ e := 0 \\
> \end{gather} %%%%%%%
>
> If LaTeX is generated for this document with
> `org-latex-export-to-latex`, which is compiled to a PDF with pdflatex,
> the "b :=" and the "e :=" are left aligned i.e. the "b" and "e" are
> vertically aligned.
>
> However, if `org-preview-latex-fragment` is called within emacs, the
> left alignment specified with the `[fleqn]` class option is not
> honoured. Thus, the two lines in the `gather` block are centrally
> aligned, which is the default case for `gather` blocks.
>

org-preview-latex-image is its own self-contained universe and has very
little in common with latex exporting. In particular, the preview
preamble is generated by calling org-create-formula--latex-header. Try
evaluating a call to the function in your *scratch* buffer and see what
it gives you - I get:

,----
| (org-create-formula--latex-header)
| "\\documentclass{article}
| \\usepackage[usenames]{color}
| % Package minted omitted
| \\usepackage[utf8]{inputenc}
| \\usepackage[T1]{fontenc}
| % Package fixltx2e omitted
| \\usepackage{graphicx}
| % Package longtable omitted
| % Package float omitted
| % Package wrapfig omitted
| % Package rotating omitted
| \\usepackage[normalem]{ulem}
| \\usepackage{amsmath}
| \\usepackage{textcomp}
| \\usepackage{marvosym}
| \\usepackage{wasysym}
| \\usepackage{amssymb}
| % Package hyperref omitted
| \\tolerance=1000
| \\pagestyle{empty}             % do not remove
| % The settings below are copied from fullpage.sty
| \\setlength{\\textwidth}{\\paperwidth}
| \\addtolength{\\textwidth}{-3cm}
| \\setlength{\\oddsidemargin}{1.5cm}
| \\addtolength{\\oddsidemargin}{-2.54cm}
| \\setlength{\\evensidemargin}{\\oddsidemargin}
| \\setlength{\\textheight}{\\paperheight}
| \\addtolength{\\textheight}{-\\headheight}
| \\addtolength{\\textheight}{-\\headsep}
| \\addtolength{\\textheight}{-\\footskip}
| \\addtolength{\\textheight}{-3cm}
| \\setlength{\\topmargin}{1.5cm}
| \\addtolength{\\topmargin}{-2.54cm}"
`----

As you can see both the document class and the class options (none)
are hardwired.

The function looks like this

,----
| (defun org-create-formula--latex-header ()
|   "Return LaTeX header appropriate for previewing a LaTeX snippet."
|   (let ((info (org-combine-plists (org-export--get-global-options
|                                  (org-export-get-backend 'latex))
|                                 (org-export--get-inbuffer-options
|                                  (org-export-get-backend 'latex)))))
|     (org-latex-guess-babel-language
|      (org-latex-guess-inputenc
|       (org-splice-latex-header
|        org-format-latex-header org-latex-default-packages-alist
|        org-latex-packages-alist t (plist-get info :latex-header)))
|      info)))
`----

so in order to add class options you have to redefine the variable
org-format-latex-header. But whatever you set them to, they will be 
hardwired: there is no way to propagate a setting from the org
file.

Nick






reply via email to

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