Improve LaTeX export of the words LaTeX and TeX

Bill Jackson writes:

> When exporting to LaTeX, the commands \LaTeX and \TeX are not
> processed consistently.  In particular, the backslash for \LaTeX is
> escaped.  This might not be a bug, but it is a bit confusing.  An
> example input file:
>
> ------------------------------------------------------------------------
>
> * The One and Only Header
>  The command \LaTeX generates an escaped backslash, while \TeX and
>  \alpha do not.  Note that LaTeX is converted to a command, while TeX
>  is not.
>
> ------------------------------------------------------------------------
>
> Typing C-c C-e l will generate the output file:
>
> ------------------------------------------------------------------------
>
> % Created 2010-01-15 Fri 13:47
> \documentclass[11pt]{article}
> \usepackage[latin1]{inputenc}
> \usepackage[T1]{fontenc}
> \usepackage{graphicx}
> \usepackage{longtable}
> \usepackage{float}
> \usepackage{wrapfig}
> \usepackage{soul}
> \usepackage{amssymb}
> \usepackage{hyperref}
>
>
> \title{escLaTeX}
> \author{}
> \date{15 January 2010}
>
> \begin{document}
>
> \maketitle
>
> \setcounter{tocdepth}{3}
> \tableofcontents
> \vspace*{1cm}
> \section{The One and Only Header}
> \label{sec-1}
>
>  The command \\LaTeX{} generates an escaped backslash, while \TeX and
>  $\alpha$ do not.  Note that \LaTeX{} is converted to a command, while TeX
>  is not.
>
> \end{document}
This commit is contained in:
Carsten Dominik 2010-01-28 15:29:35 +01:00
parent 1bb65e22d9
commit 4ba2cb0860
2 changed files with 12 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2010-01-28 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-preprocess): More consistent
conversion and protection of the words LaTeX and TeX.
2010-01-26 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-in): Improve the look of the clock line

View File

@ -1895,13 +1895,15 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
(add-text-properties beg end '(org-protected t org-latex-math t))))))
;; Convert LaTeX to \LaTeX{}
;; Convert LaTeX to \LaTeX{} and TeX to \TeX{}
(goto-char (point-min))
(let ((case-fold-search nil))
(while (re-search-forward "\\([^+_]\\)LaTeX" nil t)
(org-if-unprotected
(replace-match (org-export-latex-protect-string
(concat (match-string 1) "\\LaTeX{}")) t t))))
(while (re-search-forward "\\<\\(\\(La\\)?TeX\\)\\>" nil t)
(unless (eq (char-before (match-beginning 1)) ?\\)
(org-if-unprotected-1
(replace-match (org-export-latex-protect-string
(concat "\\" (match-string 1)
"{}")) t t)))))
;; Convert blockquotes
(goto-char (point-min))