Browse Source

LaTeX export: Protect <...> arguments for BEAMER export

Bill Jackson writes:

> When exporting to LaTeX, curly brackets in a command will be escaped
> if that command also contains angle brackets.  This can be a problem
> when using beamer.  An example input file:
>
> ------------------------------------------------------------------------
>
> #+LaTeX_CLASS: beamer
>
> * The One and Only Frame
>  When LaTeX \alert<2>{commands} contain angle brackets, the curly
>  brackets are erroneously escaped in the output.  \alert{Commands}
>  that do not contain angle brackets work properly.
>
> ------------------------------------------------------------------------
>
> Typing C-c C-e l will generate the output file:
>
> ------------------------------------------------------------------------
>
> % Created 2010-01-15 Fri 13:57
> \documentclass{beamer}
> \usepackage[latin1]{inputenc}
> \usepackage[T1]{fontenc}
> \usepackage{graphicx}
> \usepackage{longtable}
> \usepackage{float}
> \usepackage{wrapfig}
> \usepackage{soul}
> \usepackage{amssymb}
> \usepackage{hyperref}
>
>
> \title{escCurly}
> \author{}
> \date{15 January 2010}
>
> \begin{document}
>
> \maketitle
>
> \begin{frame}
> \frametitle{Outline}
> \setcounter{tocdepth}{3}
> \tableofcontents
> \end{frame}
>
> \begin{frame}
> \frametitle{The One and Only Frame}
> \label{sec-1}
>
>  When \LaTeX{} \alert<2>\{commands\} contain angle brackets, the curly
>  brackets are erroneously escaped in the output.  \alert{Commands}
>  that do not contain angle brackets work properly.
> \end{frame}
>
> \end{document}
Carsten Dominik 15 years ago
parent
commit
04057e2195
2 changed files with 8 additions and 3 deletions
  1. 2 0
      lisp/ChangeLog
  2. 6 3
      lisp/org-latex.el

+ 2 - 0
lisp/ChangeLog

@@ -2,6 +2,8 @@
 
 	* org-latex.el (org-export-latex-preprocess): More consistent
 	conversion and protection of the words LaTeX and TeX.
+	(org-export-latex-fontify-headline, org-export-latex-preprocess):
+	Allow angle brackets in commands, for beamer.
 
 2010-01-26  Carsten Dominik  <carsten.dominik@gmail.com>
 

+ 6 - 3
lisp/org-latex.el

@@ -1307,9 +1307,10 @@ links, keywords, lists, tables, fixed-width"
     ;; the beginning of the buffer - inserting "\n" is safe here though.
     (insert "\n" string)
     (goto-char (point-min))
-    (let ((re (concat "\\\\[a-zA-Z]+\\(?:"
-		      "\\[.*\\]"
-		      "\\)?"
+    (let ((re (concat "\\\\[a-zA-Z]+"
+		      "\\(?:<[^<>\n]*>\\)*"
+		      "\\(?:\\[[^][\n]*?\\]\\)*"
+		      "\\(?:<[^<>\n]*>\\)*"
 		      (org-create-multibrace-regexp "{" "}" 3))))
       (while (re-search-forward re nil t)
 	(unless (save-excursion (goto-char (match-beginning 0))
@@ -1954,7 +1955,9 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
   (goto-char (point-min))
   (let ((re (concat
 	     "\\\\[a-zA-Z]+"
+	     "\\(?:<[^<>\n]*>\\)*"
 	     "\\(?:\\[[^][\n]*?\\]\\)*"
+	     "\\(?:<[^<>\n]*>\\)*"
 	     "\\(" (org-create-multibrace-regexp "{" "}" 3) "\\)\\{1,3\\}")))
     (while (re-search-forward re nil t)
       (unless (save-excursion (goto-char (match-beginning 0))