MWE 如下:
% pdflatex test.tex; biber test; pdflatex test.tex; pdflatex test.tex
\documentclass{article}
\usepackage[autostyle=tryonce,autopunct=true]{csquotes}
\usepackage[%
style=ieee,
isbn=true,
doi=false,
url=true,
defernumbers=true,
sorting=nyt,
%sorting=none, % "Do not sort at all. All entries are processed in citation order." (order of appearance)
firstinits=false, % shows full first name
backend=biber
]{biblatex}
\usepackage[UKenglish,USenglish]{babel}
\addbibresource{biblatex-examples.bib}
% @book{knuth:ct:a,
% author = {Knuth, Donald E.},
% title = {The \TeX book},
% date = 1984,
\usepackage{xcolor}
\pagecolor{yellow!10}
% [http://www.latex-community.org/forum/viewtopic.php?f=44&t=5444 csquotes package question • Text Formatting • LaTeX Community]
% \renewenvironment{quoteblock}{\openautoquote}{\closeautoquote} % quoteblock has been removed from csquotes!
% \renewcommand{\mkblockquote}[4]{\openautoquote{\itshape#1#2}#4#3\closeautoquote} % <--! works, but changes all
% http://tex.stackexchange.com/questions/39285/whats-the-advantage-of-using-csquotes-over-using-an-editors-auto-replacement-f
\begin{document}
\hyphenquote{UKenglish}{quote with UK English hyphenation}
\textcquote[1]{knuth:ct:a}{formal quote}
\hyphentextcquote{UKenglish}[1]{knuth:ct:a}{formal quote with UK English hyphenation}
\hyphenblockcquote{UKenglish}[1]{knuth:ct:a}{A long formal quote with UK English hyphenation which happens to be longer than three lines and, thus, is typeset as a block quote. This text is just to make it long enough. This text is just to make it long enough. This text is just to make it long enough.}
\printbibliography[sorting=none]
\end{document}
...目前产生这个输出:
我想要得到的是一个以正确的引号开始和结束的块引用,里面的文本采用斜体样式,并且斜体在参考书目引用之前停止;即:
...我可以通过取消注释标有 的行来获得<--!
,即\renewcommand{\mkblockquote}[4]{\openautoquote{\itshape#1#2}#4#3\closeautoquote}
。但是,此命令会更改相对低级的\mkblockquote
命令。
所以我现在想做的是,保留默认行为\hyphenblockcquote
不变,并改为使用某种自定义的正式块引用环境。理想情况下,我希望有一种可以使用的样式选项\hyphenblockcquote
- 但如果这不可能,那么我会选择自定义命令(使用类似的语法\hyphenblockcquote
)。
csquotes
实现这一目标的推荐方法是什么?
答案1
好吧,显然我想要的是一个尚未实现的功能。我想我设法解决了这个问题:
... MWE 如下,它需要定义和使用新的用户命令,\DeclareQuoteBlockStyle
以及\setquoteblockstyle
。但是,可能需要进行一些讨论。
- 所有这些与内部和外部引用有关的事情都是仅有的
\enquote{...}
如果您在例如内部使用,则可能\hyphentextcquote
;我认为通过\MakeOuterQuote
/定义字符也是可行的\MakeAutoQuote
- 但似乎不可行。 - 当你创建样式时
\DeclareQuoteStyle
,默认情况下不是“应用”在任何地方 - 除非你碰巧用与当前选择的语言相同的名称来命名它。 - 为了“应用”/“激活”这种引用样式,您不能使用
\ExecuteQuoteOptions
或\setkeys
,因为它们仅在序言中运行;实际上有一个命令可以做到这一点,它是\setquotestyle
- 使用
csquotes
'时\DeclareQuoteAlias[variant]{style}{alias}
,请注意可以使用alias
仅有的在\setquotestyle{alias}
;你可以不是使用(浪费alias
了\hyphentextcquote{alias}...
这么多时间)。\hyphentextcquote
诸如此类多种语言命令,它们的第一个参数应该是实际的语言(如 所示babel
)。如果恰巧为\hyphentextcquote
etc. 选择的语言也有一个同名的引号样式别名,那么将应用该引号样式。 - 当你拨打
\setquotestyle[italic]{english}
(来自\DeclareQuoteStyle[italic]{english}...
)电话时,你csquotes
被迫出口“多语言模式”;然后中的语言设置就\hyphentextcquote{language}...
无关紧要了;中的引用样式\setquotestyle
优先。要返回多语言模式,请使用带星号的\setquotestyle*
(无参数)。
在寻找块引用样式的自定义时遇到了一些复杂情况;我尝试了\unravel{}
- \hyphentextcquote
,结果大约需要 14000 步,而且\mkblockquote
(鉴于 OP,这显然有影响),甚至没有显示!然而,显示的是,这是\csq@bquote@iii
调用它的唯一命令。从它的定义,很显然,除了重新定义之外,没有其他方法可以编辑块引用样式\mkblockquote
。
这就是新命令的作用:
\DeclareQuoteBlockStyle
与 相同,但它有一个额外的第一个可选参数,我们可以在其中为 指定一个“样式”\DeclareQuoteStyle
的定义;这将以从名称派生的名称保存(因此它应该能够处理多种样式);并且\mkblockquote
[variant]{style}
\setquoteblockstyle
与 相同\setquotestyle
,但它还会根据 来设置已保存的“块样式”定义,以[variant]{style}
使其\mkblockquote
处于活动状态;\setquoteblockstyle*
还会恢复\mkblockquote
到其原始定义。
请注意,一旦\setquote(block)style
正确设置了引号样式,该样式也将通过应用于区块引号\openautoquote
(如果存在于中)\mkblockquote
!因此,区块引号中的任何额外格式\mkblockquote
都将添加到添加通过设置样式\openautoquote
;这就是我\bfseries
在那里使用的原因,这样就可以在 MWE 上看到涵盖了什么。
好吧,希望我没有误解手册,而且我没有白白编写这些代码。:)
无论如何,这里 -csquotes_test.tex @gist.github.com- 是先前的测试文件,带有一些注释;最终的 MWE 是:
% pdflatex test.tex; biber test; pdflatex test.tex; pdflatex test.tex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
% \usepackage{unravel}
\usepackage[autostyle=tryonce,autopunct=true]{csquotes}
\usepackage[style=ieee, isbn=true, doi=false, url=true, defernumbers=true, sorting=nyt, firstinits=false, backend=biber]{biblatex}
\usepackage[UKenglish,USenglish]{babel}
\addbibresource{biblatex-examples.bib}
\usepackage{xcolor}
\pagecolor{yellow!10}
% start hacks:
\makeatletter
% prepare vars
\let\csq@oldblockstyle\mkblockquote
\def\csq@newblockstyle{}
% cmd to declare a quote and block style
\newrobustcmd*{\DeclareQuoteBlockStyle}[2][]{%
\let\if@safe@actives\iftrue
\ifblank{#1}
{\typeout{DQBS: 1 is blank}}
{%\def\csq@newblockstyle{#1}% new variable; but cannot handle `#1` in '#1', which \mkblockquote below needs
% save for \mkblockquote
\renewcommand{\csq@newblockstyle}[4]{#1}
\typeout{DQBS: 1 is \meaning\csq@newblockstyle} %#1}%
}
\DeclareQuoteBlockStyleI#2%
}
% helper to extract the names
\newrobustcmd*{\DeclareQuoteBlockStyleI}[2][]{%
\begingroup
\let\if@safe@actives\iftrue
\ifblank{#1}
{\typeout{DQBSI: 1 is blank, 2 is '#2'}%
% \DeclareQuoteStyle#2 % cannot, args are gobbled, must use low-level now:
\edef\csq@tempa{#2}
}%
{\typeout{DQBSI: 1 is '#1', 2 is '#2'}%
%\DeclareQuoteStyle[1]#2\expandafter % cannot...
\edef\csq@tempa{#2/#1}
}
% \let assigned vars should survive renewcommand of @newblockstyle;
% but must be global, else other code can't see it:
\global\cslet{csq@blkstyle@\csq@tempa}{\csq@newblockstyle}
\typeout{Command: csq@blkstyle@\csq@tempa -> \expandafter\meaning\csname csq@blkstyle@\csq@tempa \endcsname}
\@ifnextchar[%] % continue w/ low-level
{\csq@declareqstyle@i}
{\csq@declareqstyle@i[]}%
}
% cmd to set also block style when changing quote style
\newrobustcmd*{\setquoteblockstyle}{%
\@ifstar
{\typeout{setquoteblockstyle has to restore}%}
\let\mkblockquote\csq@oldblockstyle % restore block quote style
\setquotestyle*} % here the star is gobbled, so must re-add it manually!
{\@ifnextchar[%]
{\typeout{setquoteblockstyle has two} %'#1' and '#2'}} "! Illegal parameter number in definition"
\setquoteblockstyleI}
{\typeout{setquoteblockstyle has only one} %'#1'}}%
\setquoteblockstyleI}
}%
%\setquotestyle% proceed with original; here will also claim the * correctly and will work - but makes the \@ifstar/\@ifnextchar switch above incorrect, so must include it everywhere separately
}
% helper - so we can capture the args
\def\setquoteblockstyleI[#1]#2{%
\ifblank{#1}
{ \edef\csq@tempa{#2}%
\csletcs{mkblockquote}{csq@blkstyle@\csq@tempa}%
\setquotestyle{#2}%
}
{ \edef\csq@tempa{#2/#1}%
\typeout{mkblockquote was \meaning\mkblockquote}%
\csletcs{mkblockquote}{csq@blkstyle@\csq@tempa}%
\typeout{mkblockquote csq@blkstyle@\csq@tempa, is now \meaning\mkblockquote}% undefined
\setquotestyle[#1]{#2}%
}%
}
\makeatother
% end hacks
% the original use: (now as first opt arg in \DeclareQuoteBlockStyle)
% \renewcommand{\mkblockquote}[4]{\openautoquote{\itshape##1##2}##4##3\closeautoquote}
% \DeclareQuoteBlockStyle[]% leave like this for #1 blank...
\DeclareQuoteBlockStyle[%
\openautoquote{\bfseries#1#2}#4#3\closeautoquote% \mkblockquote contents (block style)
]%
[italics]{english}%
[\itshape]
[\normalfont]
{>\textquoteleft}
{\textquoteright<}
[0.05em]
{>{>}\textquotedblleft}
{\textquotedblright<{<}}
\DeclareQuoteAlias[italics]{english}{ITenglish}
\begin{document}
\hyphenquote{UKenglish}{quote with UK English hyphenation}
% \ExecuteQuoteOptions{english=italics} % only in preamble!
% \setkeys{csq}{english=italics} % only in preamble!
% \setquotestyle{debug} % ok
% \setquotestyle[italics]{english}
\setquoteblockstyle[italics]{english}
\textcquote[1]{knuth:ct:a}{formal quote}
\hyphentextcquote{UKenglish}[1]{knuth:ct:a}{formal quote \enquote{with UK} English hyphenation}
\MakeOuterQuote{"}
\hyphentextcquote{UKenglish}[1]{knuth:ct:a}{formal quote "with UK" English hyphenation}
\MakeAutoQuote{«}{»}
\hyphentextcquote{UKenglish}[1]{knuth:ct:a}{formal quote «with UK» English hyphenation}
\hyphenblockcquote{UKenglish}[1]{knuth:ct:a}{A long formal quote with UK English hyphenation which \enquote{happens to be longer than three lines}, thus, is typeset as a block quote. This text is just to make it long enough. This text is just to make it long enough. This text is just to make it long enough.}
% \setquotestyle*
\setquoteblockstyle*
\hyphenblockcquote{english}[1]{knuth:ct:a}{ A long formal quote with UK English hyphenation which \enquote{happens to be longer than three lines} and, thus, is typeset as a block quote. This text is just to make it long enough. This text is just to make it long enough. This text is just to make it long enough.}
\printbibliography[sorting=none]
\end{document}