2

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}
  • I thought of renewing command with \renewcommand for left and right quotes as an solution because Latex knows where its a quote and where its greek accent. I don't know which command to renew though – eklisiarh Jul 16 '14 at 15:53
  • No, the double quotes are not commands that can be renewed. – egreg Jul 16 '14 at 16:26
  • 1
    Use \enquote{random text} if you want to change quotation marks document wide. – Oliver Jul 16 '14 at 18:59
  • I am afraid in 550 pages large document that is not an option. There must be something that can be added to preamble to change this. – eklisiarh Jul 16 '14 at 19:29
  • 1
    @eklisiarh What is the problem with search & replace (or sed, which is more advanced, as Andrew suggested)? Just search for `` and replace them with . Then search for '' and replace with . That's half of the job. The single ones need a little more work… could happen that a single quote ` appears before a word? Or ' after a word? Those cases need your explicit decision, since there is no way to differentiate. Otherwise, a regular expresion (sed) might help. – Manuel Jul 19 '14 at 10:02
2
+50

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).

  • This answer solves the code in the question. Although, as @eklisiarh said in a comment, it has only a flaw: inside polutonikogreek there may be words which begin with (an accent) `, which have been converted to an opening single quote during this process. I might know how to do it with regular expressions, but it's not straightforward, so, in case anyone knows, feel free to edit. – Manuel Jul 19 '14 at 13:03
  • Do you by any chance know how I could replace all words inside the \grk{} command that begin with whitespace and an accent ` with something like whitespace$. That way I could replace the other things and than replace these things back. – eklisiarh Feb 4 '16 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.