* Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
@ 2014-04-06 20:54 Rob Stewart
2014-04-09 15:56 ` Fwd: " Rob Stewart
2014-04-17 19:07 ` Bastien
0 siblings, 2 replies; 8+ messages in thread
From: Rob Stewart @ 2014-04-06 20:54 UTC (permalink / raw)
To: emacs-orgmode
Hi,
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.
This is a screenshot of the PDF: http://imgur.com/YVRAlYP
This is a screenshot of the preview within emacs: http://imgur.com/S6BNm0K
So, is there a way to make `org-preview-latex-fragment` sensitive to
LaTeX class options?
Thanks,
--
Rob
^ permalink raw reply [flat|nested] 8+ messages in thread
* Fwd: Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
2014-04-06 20:54 Is `org-preview-latex-fragment` sensitive to alignment specified by document class options? Rob Stewart
@ 2014-04-09 15:56 ` Rob Stewart
2014-04-09 17:22 ` Nick Dokos
2014-04-17 15:29 ` Bastien
2014-04-17 19:07 ` Bastien
1 sibling, 2 replies; 8+ messages in thread
From: Rob Stewart @ 2014-04-09 15:56 UTC (permalink / raw)
To: emacs-orgmode
Hi,
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 :-)
Git blame tells me that the last commit relating to the definition of
`org-preview-latex-fragment` in lisp/org.el is fe939ec by Carsten on
22-03-2008. Who might I be able to poke directly with my question
below.
Thanks,
--
Rob
---------- Forwarded message ----------
From: Rob Stewart <robstewart57@gmail.com>
Date: 6 April 2014 21:54
Subject: Is `org-preview-latex-fragment` sensitive to alignment
specified by document class options?
To: emacs-orgmode@gnu.org
Hi,
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.
This is a screenshot of the PDF: http://imgur.com/YVRAlYP
This is a screenshot of the preview within emacs: http://imgur.com/S6BNm0K
So, is there a way to make `org-preview-latex-fragment` sensitive to
LaTeX class options?
Thanks,
--
Rob
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
2014-04-09 15:56 ` Fwd: " Rob Stewart
@ 2014-04-09 17:22 ` Nick Dokos
2014-04-10 8:23 ` Eric S Fraga
2014-04-19 13:02 ` Rob Stewart
2014-04-17 15:29 ` Bastien
1 sibling, 2 replies; 8+ messages in thread
From: Nick Dokos @ 2014-04-09 17:22 UTC (permalink / raw)
To: emacs-orgmode
Rob Stewart <robstewart57@gmail.com> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
2014-04-09 17:22 ` Nick Dokos
@ 2014-04-10 8:23 ` Eric S Fraga
2014-04-19 13:02 ` Rob Stewart
1 sibling, 0 replies; 8+ messages in thread
From: Eric S Fraga @ 2014-04-10 8:23 UTC (permalink / raw)
To: emacs-orgmode
Hi,
I am not sure if this is related but if you look at the description of
org-latex-packages-alist below, you'll see a comment about the third
argument, SNIPPET-FLAG. This may be what you need although it won't
help with document class options.
,----[ C-h v org-latex-packages-alist RET ]
| org-latex-packages-alist is a variable defined in `org.el'.
| Its value is (("" "xcolor")
| ("" "tikz")
| ("" "listings")
| ("version=3" "mhchem")
| ("" "amsmath" t))
|
| Original value was nil
|
| Documentation:
| Alist of packages to be inserted in every LaTeX header.
|
| These will be inserted after `org-latex-default-packages-alist'.
| Each element is either a cell or a string.
|
| A cell is of the format:
|
| ("options" "package" SNIPPET-FLAG)
|
| SNIPPET-FLAG, when non-nil, indicates that this package is also
| needed when turning LaTeX snippets into images for inclusion into
| non-LaTeX output.
|
| A string will be inserted as-is in the header of the document.
|
| Make sure that you only list packages here which:
|
| - you want in every file;
| - do not conflict with the setup in `org-format-latex-header';
| - do not conflict with the default packages in
| `org-latex-default-packages-alist'.
|
| You can customize this variable.
|
| [back]
`----
--
: Eric S Fraga (0xFFFCF67D), Emacs 24.4.50.2, Org release_8.2.5h-888-g798bb8
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
2014-04-09 15:56 ` Fwd: " Rob Stewart
2014-04-09 17:22 ` Nick Dokos
@ 2014-04-17 15:29 ` Bastien
1 sibling, 0 replies; 8+ messages in thread
From: Bastien @ 2014-04-17 15:29 UTC (permalink / raw)
To: Rob Stewart; +Cc: emacs-orgmode
Hi Rob,
Rob Stewart <robstewart57@gmail.com> 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 :-)
You got two answers: was one of them useful to you?
Please follow-up on issues you raise on the mailing list,
especially when you insist on getting an answer, this keeps
everyone happy to help.
Thanks!
--
Bastien
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
2014-04-06 20:54 Is `org-preview-latex-fragment` sensitive to alignment specified by document class options? Rob Stewart
2014-04-09 15:56 ` Fwd: " Rob Stewart
@ 2014-04-17 19:07 ` Bastien
1 sibling, 0 replies; 8+ messages in thread
From: Bastien @ 2014-04-17 19:07 UTC (permalink / raw)
To: Rob Stewart; +Cc: emacs-orgmode
Hi Rob,
Rob Stewart <robstewart57@gmail.com> writes:
> So, is there a way to make `org-preview-latex-fragment` sensitive to
> LaTeX class options?
Normally it should be. What version of Emacs and Org are you using?
M-x emacs-version RET
M-x org-version RET
Also, maybe have a look at `org-format-latex-header' and see if there
are no conflicting options there. Previewing combines the in-buffer
LaTeX options with those.
Best,
--
Bastien
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Fwd: Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
2014-04-09 17:22 ` Nick Dokos
2014-04-10 8:23 ` Eric S Fraga
@ 2014-04-19 13:02 ` Rob Stewart
2014-04-19 14:05 ` Fwd: " Rob Stewart
1 sibling, 1 reply; 8+ messages in thread
From: Rob Stewart @ 2014-04-19 13:02 UTC (permalink / raw)
To: Nick Dokos, emacs-orgmode
Hi Nick,
Thanks for guiding me to a solution, which was to write write my own
defcustom `my-org-format-latex-header`, changing the first line from
the definition in org.el to "\\documentclass[fleqn]{article}". This
definition I call `my-org-format-latex-header`. I then redefine
`org-create-formula--latex-header` to use
`my-org-format-latex-header`, as so:
--8<---------------cut here---------------start------------->8---
(defcustom my-org-format-latex-header "\\documentclass[fleqn]{article}
\\usepackage[usenames]{color}
\[PACKAGES]
\[DEFAULT-PACKAGES]
\\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}"
"The document header used for processing LaTeX fragments.
It is imperative that this header make sure that no page number
appears on the page. The package defined in the variables
`org-latex-default-packages-alist' and `org-latex-packages-alist'
will either replace the placeholder \"[PACKAGES]\" in this
header, or they will be appended."
:group 'org-latex
:type 'string)
(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
my-org-format-latex-header
org-latex-default-packages-alist
org-latex-packages-alist t
(plist-get info :latex-header)))
info)))
--8<---------------cut here---------------end--------------->8---
Now when I call `org-preview-latex-fragment`, the math is correctly
rendered in emacs:
http://imgur.com/mMrMIE6
My only question is: rather than using `defcustom` to define
`my-org-format-latex-header` (hence needing to redefine
`org-create-formula--latex-header`, how do I simply override the
existing definition for `org-format-latex-header`? A hasty attempt to
use setq threw the following backtrace:
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument symbolp "The
document header used for processing LaTeX fragments.
It is imperative that this header make sure that no page number
appears on the page. The package defined in the variables
`org-latex-default-packages-alist' and `org-latex-packages-alist'
will either replace the placeholder \"[PACKAGES]\" in this
header, or they will be appended.")
(setq org-format-latex-header "\\documentclass[fleqn]{article} ..
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
--8<---------------cut here---------------end--------------->8---
Thanks Nick!
--
Rob
On 9 April 2014 18:22, Nick Dokos <ndokos@gmail.com> wrote:
> Rob Stewart <robstewart57@gmail.com> 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
>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Fwd: Fwd: Is `org-preview-latex-fragment` sensitive to alignment specified by document class options?
2014-04-19 13:02 ` Rob Stewart
@ 2014-04-19 14:05 ` Rob Stewart
0 siblings, 0 replies; 8+ messages in thread
From: Rob Stewart @ 2014-04-19 14:05 UTC (permalink / raw)
To: emacs-orgmode, Nick Dokos
Maybe a spoke too soon. My answer below is partly the case. When I
turn on latexpreview with `#+STARTUP: latexpreview` then my formula is
laid out the way I intend, i.e.:
http://imgur.com/eMrwiIJ
Strangely, however, when I hit C-c C-c to remove the preview, then run
`org-preview-latex-fragment` by hand, I see:
http://imgur.com/qznnKj3
Having read through the the org-mode derived mode, me stating
`#+STARTUP: latexpreview` in my org mode triggers a call to
`org-preview-latex-fragment` in org.el:
--8<---------------cut here---------------start------------->8---
(when org-startup-with-latex-preview
(org-preview-latex-fragment))
--8<---------------cut here---------------end--------------->8---
So, what is happening between this call at startup, and me later
calling `org-preview-latex-fragment` by hand after org-mode has been
fully loaded? I have tried locating the temporary tex file that gets
generated with this call. But when `org-preview-latex-fragment is
called without errors, I cannot locate the temporary file?
--
Rob
---------- Forwarded message ----------
From: Rob Stewart <robstewart57@gmail.com>
Date: 19 April 2014 14:02
Subject: Re: [O] Fwd: Is `org-preview-latex-fragment` sensitive to
alignment specified by document class options?
To: Nick Dokos <ndokos@gmail.com>, emacs-orgmode@gnu.org
Hi Nick,
Thanks for guiding me to a solution, which was to write write my own
defcustom `my-org-format-latex-header`, changing the first line from
the definition in org.el to "\\documentclass[fleqn]{article}". This
definition I call `my-org-format-latex-header`. I then redefine
`org-create-formula--latex-header` to use
`my-org-format-latex-header`, as so:
--8<---------------cut here---------------start------------->8---
(defcustom my-org-format-latex-header "\\documentclass[fleqn]{article}
\\usepackage[usenames]{color}
\[PACKAGES]
\[DEFAULT-PACKAGES]
\\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}"
"The document header used for processing LaTeX fragments.
It is imperative that this header make sure that no page number
appears on the page. The package defined in the variables
`org-latex-default-packages-alist' and `org-latex-packages-alist'
will either replace the placeholder \"[PACKAGES]\" in this
header, or they will be appended."
:group 'org-latex
:type 'string)
(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
my-org-format-latex-header
org-latex-default-packages-alist
org-latex-packages-alist t
(plist-get info :latex-header)))
info)))
--8<---------------cut here---------------end--------------->8---
Now when I call `org-preview-latex-fragment`, the math is correctly
rendered in emacs:
http://imgur.com/mMrMIE6
My only question is: rather than using `defcustom` to define
`my-org-format-latex-header` (hence needing to redefine
`org-create-formula--latex-header`, how do I simply override the
existing definition for `org-format-latex-header`? A hasty attempt to
use setq threw the following backtrace:
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument symbolp "The
document header used for processing LaTeX fragments.
It is imperative that this header make sure that no page number
appears on the page. The package defined in the variables
`org-latex-default-packages-alist' and `org-latex-packages-alist'
will either replace the placeholder \"[PACKAGES]\" in this
header, or they will be appended.")
(setq org-format-latex-header "\\documentclass[fleqn]{article} ..
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
--8<---------------cut here---------------end--------------->8---
Thanks Nick!
--
Rob
On 9 April 2014 18:22, Nick Dokos <ndokos@gmail.com> wrote:
> Rob Stewart <robstewart57@gmail.com> 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
>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-04-19 14:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-06 20:54 Is `org-preview-latex-fragment` sensitive to alignment specified by document class options? Rob Stewart
2014-04-09 15:56 ` Fwd: " Rob Stewart
2014-04-09 17:22 ` Nick Dokos
2014-04-10 8:23 ` Eric S Fraga
2014-04-19 13:02 ` Rob Stewart
2014-04-19 14:05 ` Fwd: " Rob Stewart
2014-04-17 15:29 ` Bastien
2014-04-17 19:07 ` Bastien
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).