# Biblatex: Automatic *Vgl.* & automatic quote indenting (depending on quote length)

Is it possible to create a command that:

1. Whenever it exceeds a certain number of lines in the output (preferably 3), it will be typeset indented.
2. The citation will automatically be typeset without "Vgl." -- regardless of whether it is the short or the long form.
3. When the output is a paraphrase or summary (in other words: when the output is no citation) it is typeset with the prenote "Vgl".
4. It works in biblatex.

In Linking quotation environment with citation styles lockstep worked out a quotation command based on biblatex that automatically generates a "Vgl."-less output when used in a citation environment. And that generates a "Vgl." output when used without quotation mark.

Output-Example:

This is a paraphrase (vgl. Author 2001)

This is a paraphrase with prenote (siehe hierzu auch Author 2001)

"This is a direct quotation" (Author 2001)

The Code:

\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}


In Custom quotation style which depends on length of quotation Martin Scharrer worked out a way to generate quotations that are typeset indented or unindented -- depending on the length of the quotation. The main point with this command is: Whenever the quotation exceeds a certain number of lines in the typeset output, it will be indented.

The code:

\documentclass{article}

\makeatletter \newcommand{\cquotation}[1]{%
% \settowidth doesn't like paragraphs
\setbox\@tempboxa\hbox{%
\def\par{\hspace{3\linewidth}}% If a paragraph is included force long form
%\let\par\space  % Ignore paragraphs
#1}%
\ifdim\wd\@tempboxa>3\linewidth
\begin{quote}
\itshape
#1
\end{quote}
\else
{\itshape #1}%
\fi } \makeatother

\begin{document}

% Lipsum add paragraphs :-( \def\Text{text text text text text } \edef\Text{\Text\Text\Text\Text\Text}

\Text \cquotation{some short quote} \Text

\Text \cquotation{% Some quotation just short of three lines of text. Some quotation just short of three lines of text. Some quotation just short of three lines of text. Some quotation just short of three lines of text. Some quotation just short of three lines. } \Text

\Text \cquotation{% Some quotation shorter than three lines.

But with a paragraph inside. } \Text

\Text \cquotation{% Some quotation longer than three lines.  Some quotation longer than three lines. Some quotation longer than three lines.  Some quotation longer than three lines. Some quotation longer than three lines.  Some quotation longer than three lines. Some quotation longer than three lines.  Some quotation longer than three lines. } \Text

\end{document}

% Lipsum add paragraphs :-( \def\Text{text text text text text } \edef\Text{\Text\Text\Text\Text\Text}

\Text \cquotation{some short quote} \Text

\Text \cquotation{% Some quotation just short of three lines of text. Some quotation just short of three lines of text. Some quotation just short of three lines of text. Some quotation just short of three lines of text. Some quotation just short of three lines. } \Text

\Text \cquotation{% Some quotation longer than three lines.  Some quotation longer than three lines. Some quotation longer than three lines.  Some quotation longer than three lines. Some quotation longer than three lines.  Some quotation longer than three lines. Some quotation longer than three lines.  Some quotation longer than three lines. } \Text

\end{document}


Note. There occur two minor problems with this command.

1. Whenever you use \autocites{}{} with more than one source you will get something like vgl. Grice (1989); vgl. Levinson (2000). including more than one vgl..

2. When you use this command with autocite=footnote the counter will "jump" two steps with every \autocite that is embedded in a \cquotation{}, e.g. whenever you have something like this \cquotation{text text text \autocite{}.} the counter will add two instead of one. Thus, the numbering of your footnotes will look odd (for example 1, 2, 3, 5, 7, 8, 9 ...).

Both issues are successfully addressed in moewe's answer to Biblatex: Problems with vgl. and numbering in dynamic quotation command.

-
It seems you essentially put a copy of my answer into the original question, which now isn't really a "question" anymore. As TeX.sx is a Q+A site, please consider to rewrite your post into a proper question or at least to revert to the former version. –  lockstep Sep 28 '12 at 9:09
I've rolled back the edits to more-or-less the 'original' state. There's no problem with editing the question after it's been answered, but it really should stay in the form of a question about more-or-less the same topic. –  Joseph Wright Sep 29 '12 at 6:36
@lockstep and Joseph Wright: Ok, thank you both for your comments. Maybe I will try a more adequate re-write another day again. –  Philip Oct 2 '12 at 13:06

Assuming you want to use the citation commands of biblatex in the argument of Martin Scharrer's \cquotation command, the latter needs to be patched so that it sets the withintextquote boolean of my linked answer to true inside a group.

\documentclass{article}

\usepackage[ngerman]{babel}

\usepackage[style=authoryear]{biblatex}

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

\newbool{withintextquote}

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

\makeatletter
\newcommand{\cquotation}[1]{%
\begingroup
\booltrue{withintextquote}%
% \settowidth doesn't like paragraphs
\setbox\@tempboxa\hbox{%
\def\par{\hspace{3\linewidth}}% If a paragraph is included force long form
%\let\par\space  % Ignore paragraphs
#1}%
\ifdim\wd\@tempboxa>3\linewidth
\begin{quote}
\itshape
#1
\end{quote}
\else
{\itshape #1}%
\fi
\endgroup}
\makeatother

\usepackage{filecontents}

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

\begin{document}

\cquotation{This is a short direct quotation. \autocite{A01}}

\cquotation{This is a long direct quotation. This is a long direct
quotation. This is a long direct quotation. This is a long direct
quotation. This is a long direct quotation. This is a long direct
quotation. This is a long direct quotation. This is a long direct
quotation.\autocite{A01}}

This is a paraphrase \autocite{A01}

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

\printbibliography

\end{document}


-
Again, thank you. But there is one minor issue: Is it possible to have the brackets and the author in a non-italic font as in the paraphrases? –  Philip Jun 5 '12 at 7:58
@Philip Add \appto{\citesetup}{\upshape} to your preamble. –  lockstep Jun 5 '12 at 9:53
Thanks. It works perfectly! –  Philip Jun 5 '12 at 10:08
I am using your device in every document and I it saves me a lot of work. But now a little imperfection surfaced: \citeauthor{asdf} (where "asdf" is defined as "author = {Smith}") is typeset as "vgl. Smith" and not as "Smith" as it should be. Is it possible to get rid of this one? –  Philip Sep 10 '12 at 11:53
@Philip: As a workaround try \citeauthor[\unspace][]{asdf}. –  lockstep Sep 10 '12 at 12:33