40

I live in a funny part of the world where we're required to quote text like this: „quotes“ (note the difference between the opening and closing quote).

Is there an easy way to set up a LaTeX document so that I could just type the usual double quotes that are on my keyboard ("like this"), and the LaTeX document processor would replace them to the ones that I need („like this“)?

I know I could just use ,, (two commas) and `` (two grave accents) in the LaTeX source file, but this seems like a step-back from what Microsoft Word has to offer at this point ;-)

If LaTeX (or XeTeX, or whatever) can't do that by itself, is there a way to preprocess the LaTeX document with some sort of an regular expression (somehow embed the regexp in the document)?

EDIT:

The language in question is Lithuanian.

babel doesn't do what I want; I don't know if it's supposed to.

What I would like to achieve is the automatic "" => „“ replacement. Quoting text with anything more than a single keystroke doesn't seem efficient to me ;-)

lockstep
  • 250,273
Linas Valiukas
  • 565
  • 6
  • 9
  • 14
    Why don't you use the csquotes package? – Thorsten Dec 21 '11 at 06:48
  • Just out of curiosity what language is that? – Canageek Dec 21 '11 at 06:51
  • @Linas Did you try babel with Lithuanian? – yannisl Dec 21 '11 at 07:10
  • 1
    @Thorsten, could you give an example of how this would work with csquotes? – Linas Valiukas Dec 21 '11 at 08:38
  • @YiannisLazarides, I did, but the quotes don't get replaced (not sure if they're supposed to). – Linas Valiukas Dec 21 '11 at 08:39
  • @Canageek German is a candidate. See also http://tex.stackexchange.com/questions/10867/quotation-with-double-quote-and-o-results-in – knut Dec 21 '11 at 09:12
  • @Linas \documentclass{minimal} \usepackage[ngerman]{babel} \usepackage{csquotes} \begin{document} \enquote{Test} \end{document} – Thorsten Dec 21 '11 at 09:18
  • 1
    For single occurrence also \documentclass{article} \usepackage[T1]{fontenc} \begin{document} Text \quotedblbase text\textquotedblright{} text. \end{document} might be noted. – Stephen Dec 21 '11 at 09:29
  • We'd like to keep answers separate from questions, so you should write a separate answer instead of editing your answer ("Solution") into the question. Self-answers are perfectly admissible, and a well-written answer may earn you additional reputation. – lockstep Feb 09 '12 at 18:26

3 Answers3

40

Using the csquotes package allows logical mark up of quotes. That includes 'short' quotes, which I personally would avoid but was asked for so ...

\documentclass{article}
\usepackage[german]{babel}
\usepackage{csquotes}
\MakeOuterQuote{"}
\begin{document}
\enquote{Labas rytas}

"Labas rytas"
\end{document}

(Lithuanian babel doesn't seem to work 'out of the box', so I've used German as the standard quotation style is the same.)

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • 4
    But if the wanted language is Lithuanian, doesn't the \usepackage[german]{babel} load the German hyphenation patterns? – morbusg Dec 21 '11 at 11:12
  • 1
    @morbusg Yes, this was just so that the demo worked. I'm assuming that someone writing in Lithuanian will have a working babel set up for that language, and can therefore make the necessary adjustments to the above. (As it stands, the question does not only apply to Lithuanian, so I hope this is reasonable. After all, you could ask the same thing for German!) – Joseph Wright Dec 21 '11 at 11:16
  • 1
    I ended up doing this: \usepackage[lithuanian,german]{babel} \usepackage{csquotes} \MakeOuterQuote{"} \selectlanguage{lithuanian} – Linas Valiukas Feb 16 '12 at 19:10
6

For Czech, I get better results when using german quotations, as both German and Czech quote using 99text66, whereas croatian uses 99text99. According to https://en.wikipedia.org/wiki/Quotation_mark, the Lithuanian style should be the same as the Czech one, so I assume german would be a better option than croatian for Lithuanian as well.

The code I use to get Czech quotes is the following:

\usepackage[czech]{babel}
\usepackage{csquotes}
\DeclareQuoteAlias{german}{czech}
\MakeOuterQuote{"}

I assume this should be the correct way for Lithuanian as well, just swap czech with lithuanian in the code. I see no need to load german into babel or to use selectlanguage.

  • FYI, I am talking about Czech in the answer, because I came here from a question specifically asking for Czech quotations (http://tex.stackexchange.com/questions/109168/override-quotation-style?newreg=cde31d05f2884c94944b385366b260a0), which was marked as duplicate of this one, although it had been answered only partially. I have not found the proper way to handle Czech quotes using csquotes online and had to do my own research for that. However, I cannot add my findings as an answer to the original and more appropriate question as it had been closed as duplicate. – Rudolf U. Rosa Sep 20 '15 at 12:28
5

If you're in Windows, TeXnicCenter can also do it for you... (replacing " with the correct replacement as you type).

Werner
  • 603,163
Kaare
  • 573