![\blockquote 自定义](https://linux22.com/image/383112/%5Cblockquote%20%E8%87%AA%E5%AE%9A%E4%B9%89.png)
对于一个小组项目,我正在寻找一种直观的方式来将引言输入文档中。我使用了
\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}
因为\blockquote[Autor, Jahr]{}
我的合作伙伴可以轻松填充内容。
现在,我非常希望最后的 [Author, Year] 部分能像这个例子中的那样运行:
\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}
这有可能吗?欢迎任何指点,我已经达到编码的极限了。
泰文
编辑:在某些地方添加 \hspace*{\fill} 几乎可以起作用,但它会移动引文的引号或括号。
答案1
以下重新定义了\csq@bquote
宏,不用于\mkcitation
格式化可选参数,\blockquote
但\signed
您在aquote
环境中使用它来获得正确的格式:
\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}
要从引文中删除前导和尾随空格,可以使用:
\patchcmd\csq@bquote{#6}{\ignorespaces #6\ifhmode\unskip\fi}
{}{\GenericError{}{Patch failed}{}{}}
(环境中的\ignorespaces
和\ifhmode\unskip\fi
与 一起使用时不起作用\blockquote
)