Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When csquotes's \blockquote and displaycquote ends with a list the citation is put on the next line after the list rather than directly after the last list item. Can one force csquotes to place the citation directly after the last list item?

The following is an example that illustrates the problem:

\documentclass{article}

\usepackage{biblatex}
\usepackage{csquotes}
\usepackage{filecontents}

\begin{filecontents*}{database.bib}
@book{texbook,
  author    = {Donald E. Knuth},
  title     = {The {{\TeX}book}},
  publisher = {Addison-Wesley},
  date      = {1984}
  }
\end{filecontents*}

\bibliography{database.bib}

\begin{document}

% Bad placement of citation
\blockcquote{texbook}{%
  Some cited text:
  \begin{itemize}
  \item item 1
  \item item 2
  \end{itemize}%
}

% Bad placement of citation
\begin{displaycquote}{texbook}
  Some cited text:
  \begin{itemize}
  \item item 1
  \item item 2
  \end{itemize}
\end{displaycquote}

% Correct placement of citation
\begin{quote}
  Some cited text:
  \begin{itemize}
  \item item 1
  \item item 2 \cite{texbook}
  \end{itemize}
\end{quote}

\end{document}

The following is the output of the example. Note how the first and second citations are badly placed while the third one is correctly placed.

Output of example

share|improve this question
1  
The problem is actually more general. I have the same situation when I use csquotes' \MakeBlockQuote function and try to add a footnote. –  Simifilm May 10 '12 at 17:24
4  
You're telling to end an itemize environment, what else are you expecting? An \end{itemize} always ends a paragraph. –  egreg May 10 '12 at 18:54
    
@egreg If I end itemize after \blockcquote or displaycquote I get an error. I would simply like to typeset quotations with \blockcquote and displaycquote, even those that end with the last list item. –  N.N. May 10 '12 at 19:50
2  
@N.N. It's quite hard to understand what you want: just write ...\cite{textbook}\end{blockquote}. –  egreg May 10 '12 at 20:59
4  
Quite a tough problem. I believe that a \citehere command similar to \qedhere of amsthm could be a good way to solve the problem, but this probably requires rewriting many parts of csquotes. –  egreg May 11 '12 at 8:51
show 3 more comments

1 Answer 1

up vote 6 down vote accepted

You can locally make itemize (and other display list environments) look ahead and see if they are at the end of the quote construct, and if so, do the cite and locally disable the cite command so that it does nothing when the csquotes command executes \cite after the display.

enter image description here

\documentclass{article}

\usepackage{biblatex}
\usepackage{csquotes}
\usepackage{filecontents}

\begin{filecontents*}{database.bib}
@book{texbook,
  author    = {Donald E. Knuth},
  title     = {The {{\TeX}book}},
  publisher = {Addison-Wesley},
  date      = {1984}
  }
\end{filecontents*}
\makeatletter
\let\oldbcq\blockcquote
\let\oldendlist\endlist
\def\csq@@z{\csq@z{\csq@z}}
\def\csq@@@z{\end{displaycquote}}
\long\def\cqendlist#1\fi#2\fi#3#4{%
\def\z{#3{#4}}%
\ifx\z\csq@@@z\let\z\csq@@z\fi
\ifx\z\csq@@z
\ifhmode\unskip\fi
\leavevmode
\space \zcsqcite
\gdef\cs@next{\let\csq@cite\@gobble}%
\else
\global\let\cs@next\relax
\fi
\oldendlist#1\fi#2\fi#3{#4}%
\cs@next
}
\enditemize
\let\csq@z\relax
\def\blockcquote#1#2{\begingroup
\def\zcsqcite{\csq@cite{#1}}%
\let\enditemize\cqendlist
\oldbcq{#1}{#2\csq@z\csq@z}\endgroup}

\let\olddcq\displaycquote
\def\displaycquote#1{%
\def\zcsqcite{\csq@cite{#1}}%
\let\enditemize\cqendlist
\olddcq{#1}}

\let\oldedcq\enddisplaycquote
\def\enddisplaycquote{%
\cs@next
\oldedcq}

\makeatother
\bibliography{database.bib}

\begin{document}



% Bad placement of citation
\blockcquote{texbook}{%
  Some cited text:
  \begin{itemize}
  \item item 1
  \item item 2
  \end{itemize}}%


%\tracingall
% Bad placement of citation
\begin{displaycquote}{texbook}
  Some cited text:
  \begin{itemize}
  \item item 1
  \item item 2
  \end{itemize}
\end{displaycquote}

% Correct placement of citation
\begin{quote}
  Some cited text:
  \begin{itemize}
  \item item 1
  \item item 2 \cite{texbook}
  \end{itemize}
\end{quote}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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