# Linking quotation environment with citation styles

I was just wondering if it is possible to combine citation commands (preferably of biblatex) with quotation environments.

The reason is this:

In German language papers you often have two choices (besides some formal ones).

1. You either use a paraphrase/summary and add the source with the abbreviation "Vgl." (engl. compare).
2. Or you use a direct quotation with quotation marks and a source without "Vgl.".

Linking them together would save the author some work because it would avoid the need for manual adjustments.

Two examples:

This is a summary. (Vgl. Bauer 2009)

"This is a quotation" (Bauer 2009)

My question is:
Is it possible to define the \cite command in a quotation sensitive way that

1. automatically generates a Vgl.-less output (for example "(Bauer 2009)") when used in a quotation environment? And that
2. generates a Vgl. output (for example "(Vgl. Bauer 2009)") when used without quotation mark?
• Please be aware with phrases like: In German language papers you usually have two choices. The basic rules are defined in DIN 1505 Teil 3. – Marco Daniel May 26 '12 at 10:33
• And, to add to @MarcoDaniel’s comment, there are numerous citation styles in Germany (and elsewhere), depending on the field you work in – and in some fields every journal or department has its own style guide. – domwass May 27 '12 at 11:46

Assuming that a) "quotation environment" actually stands for text enclosed in quotation marks b) you are willing to use the csquotes package to handle quotation marks (note that its use is recommended for biblatex), you may do the following:

• Declare a new boolean switch withintextquote (which is initially set to false);

• Patch biblatex' prenote bibmacro so that it will add the (new) bibliography string compare plus a space if the withintextquote switch is set to false;

• Patch csquotes' internal \csq@tquote@i macro so that it will set the withintextquote switch locally to true.

EDIT: The automatic compare prenote is now overridden if the user adds an explicite prenote to the citation command.

\documentclass{article}

\usepackage[ngerman]{babel}

\usepackage[style=authoryear]{biblatex}

\NewBibliographyString{compare}
\DefineBibliographyStrings{ngerman}{%
}

\usepackage{csquotes}
\SetCiteCommand{\autocite}

% \usepackage{etoolbox}% loaded by biblatex

\newbool{withintextquote}

\makeatletter
\patchcmd{\csq@tquote@i}{\begingroup}{\begingroup\booltrue{withintextquote}}{}{}
\makeatother

\renewbibmacro*{prenote}{%
\iffieldundef{prenote}{%
\ifbool{withintextquote}{%
}{%
}%
}
{\printfield{prenote}%
\setunit{\prenotedelim}}}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
\end{filecontents}

\begin{document}

This is a paraphrase \autocite{A01}

This is a paraphrase with prenote \autocite[siehe hierzu auch][]{A01}

\textcquote{A01}{This is a direct quotation}

\printbibliography

\end{document}


• I suppose it works. But in my case it doesnt. The console (of TexShop 2.43) is telling me this: <argument> \ExplFileName l.30 ...e}{\ExplFileVersion}{\ExplFileDescription} – Philip May 27 '12 at 9:52
• @Philip Your version of LaTeX3 packages may be too old for xpatch. I removed the xpatch dependency in my answer. – lockstep May 27 '12 at 10:01

Since quoted text is text, and a prenote is text, then quoted text can be the prenote (at the logical level).

At the practical level:

An experiment (using macros to store and enquote the text, for potential automation later):

\cite[\qmenquote{\qmuseq{q001}} \textemdash ][]{abook}


where \qmenquote is defined as

\newcommand\qmenquote[1]{\enquote{#1}}% from the csquotes package


and \qmuseq is defined as

\newcommand\qmuseq[1]{\csname qm:#1\endcsname}


with the CS qm:q001 being defined as

\expandafter\newcommand\csname qm:q001\endcsname{The cat sat on the mat.}


gives

for a given abook entry in the bib file and english option for csquotes.

A potential use for this could be where the prenote is a variable, and the \cite is "expanded" in one version to include the quote, and in the other version to have the cf (or a paraphrase, or nothing).

This suggests the possibility of being automatic in the "vertical" dimension, rather than (or in addition to) the "horizontal" direction - that is, for example, via a loop, or a conditional. An application could be as transliterations, versus translations, versus original text.

Last item in the list in the Code:

\RequirePackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@book{abook,
author = {An Author},
title = {A Title）},
date = {2019-04-16},
location={A Location},
publisher={A Publisher},
}
\end{filecontents*}

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[english=british]{csquotes}
%\usepackage[french]{babel}
%\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}

\expandafter\newcommand\csname qm:q001\endcsname{The cat sat on the mat.}
\newcommand\mycf{\textit{Vgl.}}
\newcommand\qmuseq[1]{\csname qm:#1\endcsname}
\newcommand\qmenquote[1]{\enquote{#1}}
\newcommand\qmcite[3]{%
\if\relax\detokenize{#1}\relax \cite[\mycf][#3]{#2}\else

\begin{document}
\begin{enumerate}
\item text: \qmuseq{q001}
\item enquoted: \qmenquote{\qmuseq{q001}}

Besides \enquote, csquotes package also has the handy \textquote command.