Hi, In a certain org file I put this line into the export options: #+begin_src org-mode #+TEXT: \vspace*{0.5in} #+end_src The starred version is necessary, obviously, since this comes before any text, and LaTeX will ignore a plain old \vspace{} in those cases. This currently gets escaped as \vspace*\{0.5in\}, which keeps it from working. I noticed that regular \vspace{} is not escaped, so I went looking in org-latex.el, but can't begin to figure out which regexp in which function is protecting the unstarred version, but not the starred version. Is this fixable? Thanks! Eric
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Hi,
>
> In a certain org file I put this line into the export options:
>
> #+begin_src org-mode
> #+TEXT: \vspace*{0.5in}
> #+end_src
Should this not be
#+LATEX: \vspace*{0.5in}
instead of TEXT?
By the way, if you want such commands to be recognised inline within
normal org text, without having to escape them, I do the following:
#+latex_header: \newcommand{\Gap}[1]{\vspace*{#1}}
and then simply type \Gap{0.5in} whenever you want to invoke this vspace
command. One could argue that the latex escaping that org does should
include *'ed commands as well... but this may have other repercussions
that I am not aware of.
--
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.97.g078c0)
* lisp/org-latex.el (org-export-latex-preprocess): Correctly match starred command names. Many LaTeX commands exist in both normal and starred forms. Adjust the regexp in `org-export-latex-preprocess' to match the starred form as well. --- lisp/org-latex.el | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) Eric S Fraga wrote: > Eric Abrahamsen <eric@ericabrahamsen.net> writes: >> Hi, >> In a certain org file I put this line into the export options: >> #+begin_src org-mode >> #+TEXT: \vspace*{0.5in} >> #+end_src > Should this not be > #+LATEX: \vspace*{0.5in} > instead of TEXT? [...] > One could argue that the latex escaping that org does should > include *'ed commands as well... but this may have other repercussions > that I am not aware of. Indeed it probably should, here's a patch that does exactly that, avoiding the need for the above workaround. With this change \vspace*{1cm} is correctly exported like \vspace{1cm}. diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 2acc169..912ebba 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -2364,7 +2364,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." ;; Protect LaTeX commands like \command[...]{...} or \command{...} (goto-char (point-min)) (let ((re (concat - "\\\\\\([a-zA-Z]+\\)" + "\\\\\\([a-zA-Z]+\\*?\\)" "\\(?:<[^<>\n]*>\\)*" "\\(?:\\[[^][\n]*?\\]\\)*" "\\(?:<[^<>\n]*>\\)*" -- 1.7.4.rc2.18.gb20e9
Lawrence Mitchell <wence@gmx.li> writes:
> * lisp/org-latex.el (org-export-latex-preprocess): Correctly
> match starred command names.
>
> Many LaTeX commands exist in both normal and starred forms. Adjust
> the regexp in `org-export-latex-preprocess' to match the starred form
> as well.
Awesome! This seems like a good idea. Though the other Eric's suggestion
just to use #+LATEX of course worked perfectly, I'm not sure why I
thought I needed #+TEXT in order to place the text before the first
headline…
Eric
Patch 712 (http://patchwork.newartisans.com/patch/712/) is now "Accepted". Maintainer comment: none This relates to the following submission: http://mid.gmane.org/%3Cm3zkom15w6.fsf_-_%40e4300lm.epcc.ed.ac.uk%3E Here is the original message containing the patch: > Content-Type: text/plain; charset="utf-8" > MIME-Version: 1.0 > Content-Transfer-Encoding: 7bit > Subject: [O] Protect starred commands in LaTeX export correctly > Date: Wed, 23 Mar 2011 15:28:04 -0000 > From: Lawrence Mitchell <wence@gmx.li> > X-Patchwork-Id: 712 > Message-Id: <m3zkom15w6.fsf_-_@e4300lm.epcc.ed.ac.uk> > To: emacs-orgmode@gnu.org > > * lisp/org-latex.el (org-export-latex-preprocess): Correctly > match starred command names. > > Many LaTeX commands exist in both normal and starred forms. Adjust > the regexp in `org-export-latex-preprocess' to match the starred form > as well. > > --- > lisp/org-latex.el | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > Eric S Fraga wrote: > > > Eric Abrahamsen <eric@ericabrahamsen.net> writes: > > >> Hi, > > >> In a certain org file I put this line into the export options: > > >> #+begin_src org-mode > >> #+TEXT: \vspace*{0.5in} > >> #+end_src > > > Should this not be > > > > #+LATEX: \vspace*{0.5in} > > > instead of TEXT? > > > [...] > > > One could argue that the latex escaping that org does should > > include *'ed commands as well... but this may have other repercussions > > that I am not aware of. > > Indeed it probably should, here's a patch that does exactly that, > avoiding the need for the above workaround. With this change > \vspace*{1cm} is correctly exported like \vspace{1cm}. > > diff --git a/lisp/org-latex.el b/lisp/org-latex.el > index 2acc169..912ebba 100644 > --- a/lisp/org-latex.el > +++ b/lisp/org-latex.el > @@ -2364,7 +2364,7 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER." > ;; Protect LaTeX commands like \command[...]{...} or \command{...} > (goto-char (point-min)) > (let ((re (concat > - "\\\\\\([a-zA-Z]+\\)" > + "\\\\\\([a-zA-Z]+\\*?\\)" > "\\(?:<[^<>\n]*>\\)*" > "\\(?:\\[[^][\n]*?\\]\\)*" > "\\(?:<[^<>\n]*>\\)*" >
Lawrence Mitchell <wence@gmx.li> writes:
> * lisp/org-latex.el (org-export-latex-preprocess): Correctly
> match starred command names.
Brilliant! Thanks.
--
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.99.gac6e4.dirty)
Hi Lawrence,
Lawrence Mitchell <wence@gmx.li> writes:
> * lisp/org-latex.el (org-export-latex-preprocess): Correctly
> match starred command names.
Great -- thanks for this simple and clear patch! I've now applied it.
--
Bastien