git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Use fixltx2e package to provide '\textsubscript'.
commit869ff4344202e29ae852067c8caebb8bc2abb3ae authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 21 Apr 2012, 09:59 (14 years ago) parent9a347c3
5 files changed+8−11
src/Text/Pandoc/Writers/LaTeX.hs+2−8 templates+1−1 tests/lhs-test.latex+1 tests/lhs-test.latex+lhs+1 tests/writer.latex+3−2
src/Text/Pandoc/Writers/LaTeX.hs+2−8
@@ -56,7 +56,6 @@ data WriterState =
5656 , stEnumerate :: Bool -- true if document needs fancy enumerated lists
5757 , stTable :: Bool -- true if document has a table
5858 , stStrikeout :: Bool -- true if document has strikeout
59− , stSubscript :: Bool -- true if document has subscript
6059 , stUrl :: Bool -- true if document has visible URL link
6160 , stGraphics :: Bool -- true if document contains images
6261 , stLHS :: Bool -- true if document has literate haskell code
@@ -75,7 +74,7 @@ writeLaTeX options document =
7574 WriterState { stInNote = False, stInTable = False,
7675 stTableNotes = [], stOLLevel = 1, stOptions = options,
7776 stVerbInNote = False, stEnumerate = False,
78− stTable = False, stStrikeout = False, stSubscript = False,
77+ stTable = False, stStrikeout = False,
7978 stUrl = False, stGraphics = False,
8079 stLHS = False, stBook = writerChapters options,
8180 stCsquotes = False, stHighlighting = False,
@@ -148,7 +147,6 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
148147 [ ("fancy-enums", "yes") | stEnumerate st ] ++
149148 [ ("tables", "yes") | stTable st ] ++
150149 [ ("strikeout", "yes") | stStrikeout st ] ++
151− [ ("subscript", "yes") | stSubscript st ] ++
152150 [ ("url", "yes") | stUrl st ] ++
153151 [ ("numbersections", "yes") | writerNumberSections options ] ++
154152 [ ("lhs", "yes") | stLHS st ] ++
@@ -503,11 +501,7 @@ inlineToLaTeX (Strikeout lst) = do
503501inlineToLaTeX (Superscript lst) =
504502 inlineListToLaTeX lst >>= return . inCmd "textsuperscript"
505503inlineToLaTeX (Subscript lst) = do
506− modify $ \s -> s{ stSubscript = True }
507− contents <- inlineListToLaTeX lst
508− -- oddly, latex includes \textsuperscript but not \textsubscript
509− -- so we have to define it (using a different name so as not to conflict with memoir class):
510− return $ inCmd "textsubscr" contents
504+ inlineListToLaTeX lst >>= return . inCmd "textsubscript"
511505inlineToLaTeX (SmallCaps lst) =
512506 inlineListToLaTeX lst >>= return . inCmd "textsc"
513507inlineToLaTeX (Cite cits lst) = do
templates+1−1

Submodule changed.

tests/lhs-test.latex+1
@@ -1,6 +1,7 @@
11\documentclass[]{article}
22\usepackage{amssymb,amsmath}
33\usepackage{ifxetex,ifluatex}
4+\usepackage{fixltx2e} % provides \textsubscript
45\ifxetex
56 \usepackage{fontspec,xltxtra,xunicode}
67 \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
tests/lhs-test.latex+lhs+1
@@ -1,6 +1,7 @@
11\documentclass[]{article}
22\usepackage{amssymb,amsmath}
33\usepackage{ifxetex,ifluatex}
4+\usepackage{fixltx2e} % provides \textsubscript
45\ifxetex
56 \usepackage{fontspec,xltxtra,xunicode}
67 \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
tests/writer.latex+3−2
@@ -1,6 +1,7 @@
11\documentclass[]{article}
22\usepackage{amssymb,amsmath}
33\usepackage{ifxetex,ifluatex}
4+\usepackage{fixltx2e} % provides \textsubscript
45\ifxetex
56 \usepackage{fontspec,xltxtra,xunicode}
67 \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
@@ -54,7 +55,6 @@
5455\usepackage[normalem]{ulem}
5556% avoid problems with \sout in headers with hyperref:
5657\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
57−\newcommand{\textsubscr}[1]{\ensuremath{_{\scriptsize\textrm{#1}}}}
5858\setlength{\parindent}{0pt}
5959\setlength{\parskip}{6pt plus 2pt minus 1pt}
6060\setlength{\emergencystretch}{3em} % prevent overfull lines
@@ -596,7 +596,8 @@ This is code: \texttt{\textgreater{}}, \texttt{\$}, \texttt{\textbackslash{}},
596596Superscripts: a\textsuperscript{bc}d a\textsuperscript{\emph{hello}}
597597a\textsuperscript{hello~there}.
598598
599−Subscripts: H\textsubscr{2}O, H\textsubscr{23}O, H\textsubscr{many~of~them}O.
599+Subscripts: H\textsubscript{2}O, H\textsubscript{23}O,
600+H\textsubscript{many~of~them}O.
600601
601602These should not be superscripts or subscripts, because of the unescaped
602603spaces: a\^{}b c\^{}d, a\textasciitilde{}b c\textasciitilde{}d.