@@ -174,9 +174,11 @@ elementToLaTeX opts (Sec level _ id' title' elements) = do
174174
175175-- escape things as needed for LaTeX
176176stringToLaTeX :: Bool -> String -> State WriterState String
177−stringToLaTeX _ [] = return ""
178−stringToLaTeX isUrl (x:xs) = do
177+stringToLaTeX _ [] = return ""
178+stringToLaTeX isUrl (x:xs) = do
179+ opts <- gets stOptions
179180 rest <- stringToLaTeX isUrl xs
181+ let ligatures = writerTeXLigatures opts
180182 when (x == '€') $
181183 modify $ \st -> st{ stUsesEuro = True }
182184 return $
@@ -201,13 +203,13 @@ stringToLaTeX isUrl (x:xs) = do
201203 '[' -> "{[}" ++ rest -- to avoid interpretation as
202204 ']' -> "{]}" ++ rest -- optional arguments
203205 '\160' -> "~" ++ rest
204− '\x2018' -> "`" ++ rest
205− '\x2019' -> "'" ++ rest
206− '\x201C' -> "``" ++ rest
207− '\x201D' -> "''" ++ rest
208206 '\x2026' -> "\\ldots{}" ++ rest
209− '\x2014' -> "---" ++ rest
210− '\x2013' -> "--" ++ rest
207+ '\x2018' | ligatures -> "`" ++ rest
208+ '\x2019' | ligatures -> "'" ++ rest
209+ '\x201C' | ligatures -> "``" ++ rest
210+ '\x201D' | ligatures -> "''" ++ rest
211+ '\x2014' | ligatures -> "---" ++ rest
212+ '\x2013' | ligatures -> "--" ++ rest
211213 _ -> x : rest
212214
213215-- | Puts contents into LaTeX command.
@@ -536,23 +538,11 @@ inlineToLaTeX (Code (_,classes,_) str) = do
536538 Just h -> modify (\st -> st{ stHighlighting = True }) >>
537539 return (text h)
538540 rawCode = liftM (text . (\s -> "\\texttt{" ++ s ++ "}"))
539− $ stringToLaTeX False str
540−inlineToLaTeX (Quoted SingleQuote lst) = do
541− contents <- inlineListToLaTeX lst
542− csquotes <- liftM stCsquotes get
543− if csquotes
544− then return $ "\\enquote" <> braces contents
545− else do
546− let s1 = if (not (null lst)) && (isQuoted (head lst))
547− then "\\,"
548− else empty
549− let s2 = if (not (null lst)) && (isQuoted (last lst))
550− then "\\,"
551− else empty
552− return $ char '`' <> s1 <> contents <> s2 <> char '\''
553−inlineToLaTeX (Quoted DoubleQuote lst) = do
541+ $ stringToLaTeX False str
542+inlineToLaTeX (Quoted qt lst) = do
554543 contents <- inlineListToLaTeX lst
555544 csquotes <- liftM stCsquotes get
545+ opts <- gets stOptions
556546 if csquotes
557547 then return $ "\\enquote" <> braces contents
558548 else do
@@ -562,7 +552,16 @@ inlineToLaTeX (Quoted DoubleQuote lst) = do
562552 let s2 = if (not (null lst)) && (isQuoted (last lst))
563553 then "\\,"
564554 else empty
565− return $ "``" <> s1 <> contents <> s2 <> "''"
555+ let inner = s1 <> contents <> s2
556+ return $ case qt of
557+ DoubleQuote ->
558+ if writerTeXLigatures opts
559+ then text "``" <> inner <> text "''"
560+ else char '\x201C' <> inner <> char '\x201D'
561+ SingleQuote ->
562+ if writerTeXLigatures opts
563+ then char '`' <> inner <> char '\''
564+ else char '\x2018' <> inner <> char '\x2019'
566565inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str
567566inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$'
568567inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]"