每章开头的引文

每章开头的引文

我想在章节开头添加如下图所示的引文,但我似乎不知道该怎么做 :(

这是我现在一直在用的,但我喜欢这个。你能帮忙吗?谢谢 :) 祝你有美好的一天

\documentclass[11pt]{book}

\usepackage{microtype}
\usepackage{times}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{lipsum}
%%%%*************************************************
% fancy quotes
\definecolor{quotemark}{gray}{0.7}
\makeatletter
\def\fquote{%
  \@ifnextchar[{\fquote@i}{\fquote@i[]}%]
}

\def\fquote@i[#1]{%
  \def\tempa{#1}%
  \@ifnextchar[{\fquote@ii}{\fquote@ii[]}%]
}%

\def\fquote@ii[#1]{%
  \def\tempb{#1}%
  \@ifnextchar[{\fquote@iii}{\fquote@iii[]}%]
}%

\def\fquote@iii[#1]{%
  \def\tempc{#1}%
  \vspace{1em}%
  \noindent%
  \begin{list}{}{%
    \setlength{\leftmargin}{0.1\textwidth}%
    \setlength{\rightmargin}{0.1\textwidth}%
  }%
    \item[]%
      \begin{picture}(0,0)%
        \put(-15,-5){\makebox(0,0){\scalebox{3}
          {\textcolor{quotemark}{``}}}}%
      \end{picture}%
      \begingroup\itshape}%
\def\endfquote{%
  \endgroup\par%
  \makebox[0pt][l]{%
    \hspace{0.8\textwidth}%
    \begin{picture}(0,0)(0,0)%
      \put(15,15){\makebox(0,0){%
        \scalebox{3}{\color{quotemark}''}}}%
    \end{picture}}%
  \ifx\tempa\empty%
  \else%
    \ifx\tempc\empty%
      \hfill\rule{100pt}{0.5pt}\\\mbox{}\hfill\tempa,\
      \emph{\tempb}%
    \else%
      \hfill\rule{100pt}{0.5pt}\\\mbox{}\hfill\tempa,\
      \emph{\tempb},\ \tempc%
    \fi\fi\par%
  \vspace{0.5em}%
  \end{list}}
\makeatother

%%%*********************************************

\begin{document}
  \chapter{Graph theory}
  \begin{fquote}[Confucius]Our greatest glory is not in
    never falling, but in rising every time we fall.
  \end{fquote}
  \lipsum[2]
  \begin{fquote}[Lewis Carroll][Alice in Wonderland]
    [1899]Begin at the beginning,'' the King said,
    gravely, ``
  \end{fquote}
  \lipsum[2]
\end{document}

在此处输入图片描述

答案1

建立在冥王星回答章节开头的“励志”引言我们可以得出以下结论

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{libertinus}
\usepackage{microtype}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{csquotes}
\usepackage{lipsum}

\definecolor{quotemark}{gray}{0.7}
\makeatletter
\newlength\origparskip

\newcommand{\fquote}{%
  \@ifnextchar[{\fquote@i}{\fquote@i[]}%]
}

\def\fquote@i[#1]{%
  \@ifnextchar[{\fquote@ii{#1}}{\fquote@ii{#1}[]}%]
}%

\def\fquote@ii#1[#2]{%
  \def\pqm@tempa{#1}%
  \def\pqm@tempb{#2}%
  \noindent
  \list
    {}
    {\setlength{\leftmargin}{0.3\textwidth}%
     \setlength{\rightmargin}{0.1\textwidth}%
     \setlength{\origparskip}{\parskip}}%
    \item[]%
      \begin{picture}(0,0)%
        \put(-15,-8){\makebox(0,0){\scalebox{4}{%
          \textcolor{quotemark}{\textquotedblright}}}}%
      \end{picture}%
      \begingroup
      \itshape
      \ignorespaces}%

\def\endfquote{%
  \endgroup
  \par
  \raggedleft
  \ifx\pqm@tempa\empty
  \else
    {\bfseries --- \pqm@tempa\par}%
    \setlength{\parskip}{\origparskip}%
    \ifx\pqm@tempb\empty
    \else
      (\pqm@tempb)%
    \fi
  \fi
  \par
  \endlist}
\makeatother

\begin{document}
  \chapter{Graph theory}
  \begin{fquote}[Wim Crouwel][Graphic designer and typographer]
    You can’t do better design with a computer, but you can speed up your work enormously.
  \end{fquote}
  \lipsum[2]
  \begin{fquote}[Wim Crouwel]
    You can’t do better design with a computer, but you can speed up your work enormously.
  \end{fquote}
  \lipsum[2]
\end{document}

代码已更改为仅输出左引号,并且fquote现在仅接受两个可选参数:一个用于名称,一个用于括号插入。

结果截图

答案2

我不确定我是否完全理解了你想要什么,但这是我基于 提出的建议epigraph。我用基于 Times 克隆的替换了过时的times 包:newtxtext, newtxmathTeX Gyre Termes

\documentclass[11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{newtxtext, newtxmath}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[svgnames]{xcolor}
\usepackage{lipsum}
%%%%*************************************************
\usepackage{tabularx}
\usepackage{epigraph}
\setlength{\epigraphwidth}{0.6\textwidth}
\setlength{\epigraphrule}{0pt}
%%%*********************************************
\newcommand{\myopeningquote}{\smash{\raisebox{-1.25\height}{\llap{\scalebox{3}
          {\textcolor{Silver}{``}}\,}}}}
\newcommand{\myclosingquote}{\raisebox{-0.66\height}{\scalebox{3}{\textcolor{Silver}{”}}}}

\begin{document}

  \chapter{Graph theory}

\epigraph{\itshape\myopeningquote Our greatest glory is not in never falling, but in rising every time we fall.\myclosingquote}
{Confucius}%

  \lipsum[2]

\epigraph{\itshape\myopeningquote Begin at the beginning,'' the King said,
    gravely,\myclosingquote}
{Lewis Carroll, \emph{Alice in Wonderland} (1865)}%

  \lipsum[2]

\end{document} 

在此处输入图片描述

相关内容