[Tex/LaTex] Changing english quotation marks to german + greek text

csquotespunctuation

I need to change english quotation marks: “text” into german quotation marks: „text“ through out my entire document.

The problem is I used “text'' and `text' in the entire document.

There is another complication. I also have a lot of greek text in the document which is using both ` and ' to produce accents.

Is there a way to add something to the preamble to change this throughout the document?

Here is my MWE:

\documentclass{scrartcl}
\usepackage[polutonikogreek,ngerman]{babel}%
\usepackage[babel,german=quotes]{csquotes}

\begin{document}
``Double quotes''

`Single quotes'

\foreignlanguage{polutonikogreek}{`ouko~un t~w m`en >agenn'htw patr`i o>ike~ion >ax'iwma fulakt'eon, mhd'ena to~u e@inai a>ut~w t`on a>'ition l'egontas; t~w d`e u<i~w t`hn <arm'ozousan tim`hn >aponemht'eon, t`hn >'anarqon a>ut~w par`a to~u patr`os g'ennhsin >anatij'entas; ka`i <ws >afj'asamen a>ut~w s'ebas >apon'emontes, m'onon e>usebos ka`i e>uf'hmws t`o @hn ka`i t`o `ae'i ka`i t`o pr`o a>i'wnwn l'egontes >ep> a>uto~u, t`hn m'entoi je'othta a>uto~u m`h paraitou'menoi, `all`a t~h e>ik'oni ka`i t~w qarakt~hri to~u patr`os >aphkribwm'enhn >emf'ereian kat`a p'anta >anatij'entes, t`o d`e >ag'ennhton t~w patr`i m'onon >id'iwma pare~inai dox'azontes, <'ate d`h ka`i a>uto~u f'askontos to~u swt~hros; »<o pat'hr mou me'izwn mo'u >estin«.}
\end{document}

Best Answer

Disclaimer: I discovered regular expressions less than a month ago.

This is the easiest way I can think of, since, as others have said, ` and ' are ligatures in the font. This solution works at least in your example.

You need a system that lets you use regular expresions. In my case I used my text editor. Here you have, for instance, an online one (I don't know its limitations) regex101.

Once there, you paste your code in test string. And also open the substitution “tab” which is at the bottom. Now you are going to search and replace with regular expressions which leaves you with the replaced text at the bottom, so each step you need to copy the code in the bottom and paste it again in the top.

  1. Regular expression (\W)`` and substitution \1„.
  2. Regular expression ''(\W) and substitution “\1.
  3. Regular expression (\W)` and substitution \1,. (I used a comma here in the replacemente text since I don't know what you need)
  4. Regular expression '(\W) and substitution ‘\1.

That will leave your example text like

\documentclass{scrartcl}
\usepackage[polutonikogreek,ngerman]{babel}%
\usepackage[babel,german=quotes]{csquotes}

\begin{document}
„Double quotes“

,Single quotes‘

\foreignlanguage{polutonikogreek}{o>uko~un t~w m`en >agenn'htw patr`i o>ike~ion >ax'iwma fulakt'eon, mhd'ena to~u e@inai a>ut~w t`on a>'ition l'egontas; t~w d`e u<i~w t`hn <arm'ozousan tim`hn >aponemht'eon, t`hn >'anarqon a>ut~w par`a to~u patr`os g'ennhsin >anatij'entas; ka`i <ws >afj'asamen a>ut~w s'ebas >apon'emontes, m'onon e>usebos ka`i e>uf'hmws t`o @hn ka`i t`o >ae`i ka`i t`o pr`o a>i'wnwn l'egontes >ep> a>uto~u, t`hn m'entoi je'othta a>uto~u m`h paraitou'menoi, >all`a t~h e>ik'oni ka`i t~w qarakt~hri to~u patr`os >aphkribwm'enhn >emf'ereian kat`a p'anta >anatij'entes, t`o d`e >ag'ennhton t~w patr`i m'onon >id'iwma pare~inai dox'azontes, <'ate d`h ka`i a>uto~u f'askontos to~u swt~hros; »<o pat'hr mou me'izwn mo'u >estin«.}
\end{document}

Which seems right (except for the comma I used instead of an opening low quote :D).


A little explanation. \W searches for a non-letter (that is, something that is not [a-zA-Z0-9_], with the parenthesis (\W) you save its content into \1. So searching for '(\W) will search for a quote and a non letter which removes the possibility of selecting it when it's inside a word. Now the replacement is ‘\1 which is what you want, you change the quote and re-insert the non-letter you grabbed in the search (so you don't loose it).

Related Question