0

For a group-project I am looking for an intuitive way to enter quotes into a document. I used this

\newlength{\cmfapaparindent} %neue Länge 'cmfapaparindent' 
\setlength{\cmfapaparindent}{0.75cm}%setzen der Länge 

%\usepackage[thresholdtype=words,threshold=3]{csquotes}

\renewcommand{\mkblockquote}[4]{\textooquote#1#2\textcoquote#4#3} 

\newenvironment{myquote} { 
\setlength{\leftmargini}{\cmfapaparindent} %Einrückung von quotes 
\quote\sffamily 
} { 
\unskip 
\endquote 
} 
% `csquotes' sagen, dass es statt `quote' `myquote' verwenden soll: 
\SetBlockEnvironment{myquote} 

since \blockquote[Autor, Jahr]{} is easy for my partners to fill with content.

Now, I would really like to have the [Author, Year] part at the end to behave like in this example:

\documentclass{book}

\def\signed #1{{\leavevmode\unskip\nobreak\hfil\penalty50\hskip2em
  \hbox{}\nobreak\hfil(#1)%
  \parfillskip=0pt \finalhyphendemerits=0 \endgraf}}

\newsavebox\mybox
\newenvironment{aquote}[1]
  {\savebox\mybox{#1}\begin{quote}}
  {\signed{\usebox\mybox}\end{quote}}

\begin{document}

\begin{aquote}{Bourbaki}
This is a case where the name fits in nicely with the quote so the name will appear in the same line.
\end{aquote}

\begin{aquote}{Nicolas Bourbaki}
This is a case where the name won't fit in nicely with the quote, and in this case the name will be moved to the next line.
\end{aquote}

\end{document}

Is that at all possible? Any pointers would be welcome, I am hitting the limits of my coding here.

Tyvm

edit: adding \hspace*{\fill} in some places almost works, but it either moves the quotation marks or the brackets of the citation.

1 Answers1

2

The following redefines the \csq@bquote macro to not use \mkcitation to format the optional argument of \blockquote but \signed which you used in the aquote environment to get the correct formatting:

\documentclass{book}

\def\signed #1{{\leavevmode\unskip\nobreak\hfil\penalty50\hskip2em
  \hbox{}\nobreak\hfil(#1)%
  \parfillskip=0pt \finalhyphendemerits=0 \endgraf}}

\newlength{\cmfapaparindent} %neue Länge 'cmfapaparindent' 
\setlength{\cmfapaparindent}{0.75cm}%setzen der Länge 

\usepackage[thresholdtype=words,threshold=3]{csquotes}

\renewcommand{\mkblockquote}[4]{\textooquote#1#2\textcoquote#4#3} 

\newenvironment{myquote}
  {% 
    \setlength{\leftmargini}{\cmfapaparindent}% Einrückung von quotes 
    \quote\sffamily
    \ignorespaces
  }
  {% 
    \ifhmode\unskip\fi
    \endquote 
  } 
\SetBlockEnvironment{myquote} 

\usepackage{etoolbox}

\makeatletter
\patchcmd\csq@bquote{#3}{\signed}{}{\GenericError{}{Patch failed}{}{}}
\makeatother

\begin{document}

\blockquote[Bourbaki, Nicolas]
  {%
    This is a case where the name won't fit in nicely with the quote, and in
    this case the name will be moved to the next line.% 
  }

\blockquote
  {%
    This is a case where the name won't fit in nicely with the quote, and in
    this case the name will be moved to the next line.% 
  }
\end{document}

enter image description here

To remove leading and trailing whitespace from the quote one could use:

\patchcmd\csq@bquote{#6}{\ignorespaces #6\ifhmode\unskip\fi}
  {}{\GenericError{}{Patch failed}{}{}}

(the \ignorespaces and \ifhmode\unskip\fi in the environment don't take effect when used with \blockquote)

Skillmon
  • 60,462