Automatic german quotation marks

I’d use csquotes, with " defined as outer quotation mark, like in

\documentclass[ngerman]{article}

\usepackage{babel}
\usepackage{csquotes}
\MakeOuterQuote{"}

\begin{document}
"Deutscher" Text
\end{document}

german quotes

You can also define a symbol for inner quotations with \MakeInnerQuote{<symbol>} or an automated solution which decides wether to use outer or inner quote with \MakeAutoQuote{<open>}{<close>} where the two characters must be different, e.g. \MakeAutoQuote{<}{>} (use: <Deutscher> Text) …


Please note, that \MakeOuterQuote{"} overwrites some of babel’s shorthands in certain languages like "= in (n)german. In that was it might be better to use another character for active quotes or no active quotes and \enquote instead. Otherwise on could define own macros for babel shorthands like

\makeatletter
\newcommand{\diviswithhiphenation}{\penalty\@M-\hskip\z@skip}
% defined like "= in babel-contrib/german/ngermanb.dtx
\makeatother

Probably this will cause some other troubles, but here it is.

Elaborating a bit on this answer of Martin Scharrer, this is the result:

enter image description here

Code:

\documentclass{article}
\usepackage[ngerman]{babel}

\let\oldquote'
\newif\ifquoteopen
\catcode`\'=\active
\makeatletter
\DeclareRobustCommand*{'}{%
   \@ifnextchar'{%
     \ifquoteopen
       \global\quoteopenfalse\grqq\expandafter\@gobble
     \else
       \global\quoteopentrue\glqq\expandafter\@gobble
     \fi
   }{\oldquote}%
}
\makeatother

\begin{document}
\section{Using ''quotes''}
A ''quote'' and one with a period that follows: ''quote''. And a single 'quote'.

\noindent
And this is the original one: \glqq quote\grqq.
\end{document} 

If the meaning of ' in math mode is to be preserved, some other hacks are needed:

\documentclass{article}
\usepackage[ngerman]{babel}

\let\oldquote'
\newif\ifquoteopen
\catcode`\'=\active
\makeatletter
% we have to redefine \pr@m@s to use an active '
\def\pr@m@s{%
  \ifx'\@let@token
    \expandafter\pr@@@s
  \else
    \ifx^\@let@token
      \expandafter\expandafter\expandafter\pr@@@t
    \else
      \egroup
    \fi
  \fi}
\protected\def'{%
  \ifmmode
    \expandafter\active@math@prime
  \else
    \expandafter\active@text@prime
  \fi}
\def\active@text@prime{%
   \@ifnextchar'{%
     \ifquoteopen
       \global\quoteopenfalse\grqq\expandafter\@gobble
     \else
       \global\quoteopentrue\glqq\expandafter\@gobble
     \fi
   }{\oldquote}%
}
\makeatother

\begin{document}
\section{Using ''quotes''}
A ''quote'' and one with a period that follows: ''quote''. And a single 'quote'.

\noindent
And this is the original one: \glqq quote\grqq.

\noindent
Some derivatives $f'(x)+g''(x)$.
\end{document} 

enter image description here


This last solution also transforms single quotes into German ones:

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{xspace}

\let\oldquote'
\newif\ifquoteopen
\catcode`\'=\active
\makeatletter
% we have to redefine \pr@m@s to use an active '
\def\pr@m@s{%
  \ifx'\@let@token
    \expandafter\pr@@@s
  \else
    \ifx^\@let@token
      \expandafter\expandafter\expandafter\pr@@@t
    \else
      \egroup
    \fi
  \fi}
\protected\def'{%
  \ifmmode
    \expandafter\active@math@prime
  \else
    \expandafter\active@text@prime
  \fi}
\def\active@text@prime{%
   \@ifnextchar'{%
     \ifquoteopen
       \global\quoteopenfalse\grqq\expandafter\@gobble
     \else
       \global\quoteopentrue\glqq\expandafter\@gobble
     \fi
   }{%
     \ifquoteopen
       \global\quoteopenfalse\grq\xspace
     \else
       \global\quoteopentrue\glq
     \fi
   }%
}
\makeatother

\begin{document}
\section{Using ''quotes''}
A ''quote'' and one with a period that follows: ''quote''. A single 'quote' and one with a period that follows: 'quote'.

\noindent
And these are the original ones: \glqq quote\grqq{} and \glq quote\grq.

\noindent
Some derivatives $f'(x)+g''(x)$.
\end{document} 

enter image description here


The most portable way is to use the \enquote command which is defined in the csquotes package. Maybe you want to change the quote style later to guillemets (>> foo <<), then all you have to do is to change the package option to \usepackage[german=guillemets]{csquotes}.

\documentclass[a4paper]{scrartcl}

\usepackage[german]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[german=quotes]{csquotes}

\begin{document}
    Text without quotes. \enquote{Text with quotes}.
\end{document}