在页边空白处用大引号标出引用内容

在页边空白处用大引号标出引用内容

我非常喜欢 Herbert 对这个问题的解决方案大引号引用看起来像这样:

在此处输入图片描述

\documentclass{article}
\thispagestyle{empty}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\makeatletter

\tikzset{%
  fancy quotes/.style={
    text width=\fq@width pt,
    align=justify,
    inner sep=1em,
    anchor=north west,
    minimum width=\linewidth,
  },
  fancy quotes width/.initial={.8\linewidth},
  fancy quotes marks/.style={
    scale=8,
    text=white,
    inner sep=0pt,
  },
  fancy quotes opening/.style={
    fancy quotes marks,
  },
  fancy quotes closing/.style={
    fancy quotes marks,
  },
  fancy quotes background/.style={
    show background rectangle,
    inner frame xsep=0pt,
    background rectangle/.style={
      fill=gray!25,
      rounded corners,
    },
  }
}

\newenvironment{fancyquotes}[1][]{%
\noindent
\tikzpicture[fancy quotes background]
\node[fancy quotes opening,anchor=north west] (fq@ul) at (0,0) {``};
\tikz@scan@one@point\pgfutil@firstofone([email protected])
\pgfmathsetmacro{\fq@width}{\linewidth - 2*\pgf@x}
\node[fancy quotes,#1] (fq@txt) at ([email protected] west) \bgroup}
{\egroup;
\node[overlay,fancy quotes closing,anchor=east] at ([email protected] east) {''};
\endtikzpicture}

\makeatother

\begin{document}
\lipsum[1]

\begin{fancyquotes}
\lipsum[1]
\end{fancyquotes}

\lipsum[1]
\end{document}

是否可以将引号移到边距中,使得引用的文本的宽度与 \textwidth 几乎相同?

答案1

以下是 Herbert 想法的一个实现tcolorbox

截屏

下面代码的重要部分是:

\newtcolorbox{fancyquotes}{%
        enhanced jigsaw, 
        breakable,      % allow page breaks
        frame hidden,   % hide the default frame
        left=0cm,       % left margin
        right=0cm,      % right margin
        overlay={%
            \node [scale=8,
                text=black,
                inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 
            \node [scale=8,
                text=black,
                inner sep=0pt,] at ([xshift=1cm]frame.south east){''};  
                },
            % paragraph skips obeyed within tcolorbox
                    parbox=false,
    }

它定义了一个newenvironment允许分页符并在环境的左上角和右下角有引号的。根据需要调整键!

完整代码如下:

% arara: pdflatex
\documentclass{article}
\usepackage{lipsum}
\usepackage[many]{tcolorbox}

\newtcolorbox{fancyquotes}{%
    enhanced jigsaw, 
    breakable,      % allow page breaks
    frame hidden,   % hide the default frame
    left=0cm,       % left margin
    right=0cm,      % right margin
    overlay={%
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=1cm]frame.south east){''};  
            },
        % paragraph skips obeyed within tcolorbox
                parbox=false,
}

\begin{document}
\lipsum[1]

\begin{fancyquotes}
    \lipsum[1]
\end{fancyquotes}

\lipsum[1]

\begin{fancyquotes}
    \lipsum
\end{fancyquotes}

\end{document}

如果您希望页面损坏环境的行为有所不同,那么您可以按如下方式调整环境,例如,

\newtcolorbox{fancyquotes}{%
    enhanced jigsaw, 
    breakable,      % allow page breaks
    frame hidden,   % hide the default frame
    left=0cm,       % left margin
    right=0cm,      % right margin
    overlay  unbroken={%
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=1cm]frame.south east){''};  
    },
    % if you wish to have the look different for page-broken boxes, adjust the following
    overlay first={%
    \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=-1cm,yshift=-1cm]frame.north west){``}; 
    },
    overlay middle={},
    overlay last={%
        \node [scale=8,
            text=black,
            inner sep=0pt,] at ([xshift=1cm]frame.south east){''};  
    },
    % paragraph skips obeyed within tcolorbox
    parbox=false,
}

这会将引号放在开头和结尾,但不放在“中间”部分,即跨分页符。

相关内容