将引用段落的宽度设置为比正文窄

将引用段落的宽度设置为比正文窄

我使用 dirtytalk 包,带有 UK 字形。当前设置产生以下输出,其中正文和引文的宽度相同。我想要做的是每次在文档中引用时,默认将引用文本的段落宽度设置为比正文窄。我该怎么做? 在此处输入图片描述

\documentclass{report}
\usepackage[british]{babel}
\usepackage[
    left = `,% 
    right = ',% 
    leftsub = ``,% 
    rightsub = '' %
]{dirtytalk}

\begin{document}

I use the dirtytalk package, with UK glyphs. What I want to do is to set the width of paragraph for quoted texts narrower than the main body by default every time I quote in the document. How can I do this? The current settings produce the following outputs.

\say{All the world’s a stage, and all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts.}  (Shakespeare, As You Like It, Act 2, Scene 7)

\end{document}

答案1

\say如果当前级别为 1,则可以将内置的 LaTeX 引用环境添加到命令中:

\documentclass{report}
\usepackage[british]{babel}
\usepackage[
    left = `,% 
    right = ',% 
    leftsub = ``,% 
    rightsub = '' %
]{dirtytalk}

\makeatletter
% definition copied from dirtytalk.sty
\renewcommand{\say}[1]%
  {%
    \addtocounter{dirtytalk@qdepth}{1}%
    % added the line below
    \ifnum\thedirtytalk@qdepth=1\begin{quote}\fi%
    \dirtytalk@lsymb%
    #1%
    \dirtytalk@rsymb%
    % close the environment
    \ifnum\thedirtytalk@qdepth=1\end{quote}\fi%
    \addtocounter{dirtytalk@qdepth}{-1}%
  }
\makeatother

\begin{document}

I use the dirtytalk package, with UK glyphs. What I want to do is to set the width of paragraph for quoted texts narrower than the main body by default every time I quote in the document. How can I do this? The current settings produce the following outputs.

\say{All the world’s a stage, and all the men and women merely players. They have their \say{exits} and their \say{entrances}; And one man in his time plays many parts.}  (Shakespeare, As You Like It, Act 2, Scene 7)

\end{document}

在此处输入图片描述


编辑:添加了一个带有可选参数的版本,将引用的来源与引用本身对齐,以用作\say[author]{quote}

\documentclass{report}
\usepackage[british]{babel}
\usepackage[
    left = `,% 
    right = ',% 
    leftsub = ``,% 
    rightsub = '' %
]{dirtytalk}

\makeatletter
\renewcommand{\say}[2][]%
  {%
    \addtocounter{dirtytalk@qdepth}{1}%
    \ifnum\thedirtytalk@qdepth=1\begin{quote}\fi%
    \dirtytalk@lsymb%
    #2%
    \dirtytalk@rsymb%
    \ifnum\thedirtytalk@qdepth=1\end{quote}\fi%
    \addtocounter{dirtytalk@qdepth}{-1}%
    \ifx\relax#1\relax\else\vskip-1em\hspace{\leftmargin}(#1)\vskip1em\fi
  }
\makeatother

\begin{document}

I use the dirtytalk package, with UK glyphs. What I want to do is to set the width of paragraph for quoted texts narrower than the main body by default every time I quote in the document. How can I do this? The current settings produce the following outputs.

\say[Shakespeare, As You Like It, Act 2, Scene 7]{All the world’s a stage, and all the men and women merely players. They have their \say{exits} and their \say{entrances}; And one man in his time plays many parts.}

The next paragraph starts with an indent on the first line, as paragraphs do by default, and the second line starts at the edge of the page content which is rather far from the edge of the page itself in regular \LaTeX\ classes.

\say{This quote has no author}

The next paragraph starts with an indent on the first line again.

\end{document}

在此处输入图片描述

如果您认为这太复杂,那么您也可以使用第一个定义并\vskip-1em\hspace{\leftmargin}(Shakespeare etc.)\vskip1em手动添加。

答案2

我建议使用该quoting包,它定义了用于自定义报价和引用环境的命令,并且默认在两侧缩进:

\documentclass{report}
\usepackage[british]{babel}
\usepackage{quoting}

\begin{document}

I use the \emph{dirtytalk} package, with UK glyphs. What I want to do is to set the width of paragraph for quoted texts narrower than the main body by default every time I quote in the document. How can I do this? The current settings produce the following outputs.

\begin{quoting}[begintext=‘, vskip= 0.4ex, indentfirst=false]
All the world’s a stage, and all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts.’

\raggedleft(Shakespeare, \emph{As You Like It}, Act 2, Scene 7)
\end{quoting}

\end{document} 

在此处输入图片描述

相关内容