如何在空白页上插入随机引语

如何在空白页上插入随机引语

我正在整理一本书。empty由于新章节的缘故,有几处地方我加了页码。我想通过添加引文来美化这些页面,但我希望书中有不止一个引文。

我目前在课堂上使用的方法book是:

\usepackage{lmodern}
\newlength\longest
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside%
\ifodd\c@page\else
\vspace*{\fill}

\settowidth\longest{\itshape ``but there is a miraculous feeling.''}
\hfill
\begin{center}
\parbox{\longest}{%
\raggedright{\itshape%
``The pages are still blank,\\
but there is a miraculous feeling\\
of the words being there,\\
written in invisible ink\\
and clamoring to become visible.''\par\bigskip
}
\raggedleft\scshape{Vladimir Nabokov}\par%
}
\end{center}
\vspace{\fill}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi
}
\makeatother

我真的很喜欢这个引文的结果,并且希望找到一种方法来在文档中包含几个类似格式的引文。

答案1

这是一个解决方案。选择如何显示引文,我只是将它们置于页面中央。

\documentclass[a4paper]{book}
\usepackage{varwidth}

\makeatletter
\renewcommand{\cleardoublepage}{%
  \clearpage
  \if@twoside
    \ifodd\c@page
    \else
%      \hbox{}% % this was in the original
      \thispagestyle{empty}
      \nextquotation
      \newpage
    \fi
  \fi
}
\newcounter{quotationcount}
\newcounter{defquotationcount}
\newcommand{\nextquotation}{%
  \stepcounter{quotationcount}%
  \vspace*{\fill}
  \begin{center}
  \csname randomquotation\thequotationcount\endcsname\par
  \end{center}
  \vspace*{\fill}
}
\newcommand{\newquotation}[2]{%
  \stepcounter{defquotationcount}%
  \@namedef{randomquotation\thedefquotationcount}{%
    \begin{varwidth}{.75\textwidth}
    \itshape#2\par\vspace{1ex}
    \hspace*{\fill}{\normalfont#1}
    \end{varwidth}
  }
}
\makeatother

%% The following should better go in a file
%% named, say, randomquotations.tex
%% saying here \input{randomquotations}
\newquotation{Oscar Wilde}
 {
  Whenever people agree with me \\
  I always feel I must be wrong.
 }
\newquotation{George Eliot}
 {
  Blessed is the man who, having nothing to say, \\
  abstains from giving wordy evidence of the fact.
 }
\newquotation{Ogden Nash}
 {
  I think that I shall never see \\
  a billboard lovely as a tree. \\
  Perhaps, unless the billboards fall, \\
  I'll never see a tree at all.
 }
%% end of quotations, courtesy of http://www.quotationspage.com

\begin{document}

\mainmatter

\chapter{Title}
text
\chapter{Title}
text
\chapter{Title}
text

\backmatter

% just to get another quotation
\begin{thebibliography}{1}

\end{thebibliography}

\end{document}

使用外部文件可以更轻松地添加新的引文并对其进行随机排序。

在此处输入图片描述

您可能想要添加对可用报价数量的检查:

\newcommand{\nextquotation}{%
  \stepcounter{quotationcount}%
  \vspace*{\fill}
  \begin{center}
  \ifnum\value{quotationcount}>\value{defquotationcount}
    {\Huge Hey! You need another quotation!\par}
  \else
    \csname randomquotation\thequotationcount\endcsname\par
  \fi
  \end{center}
  \vspace*{\fill}
}

引文摘自引文页面

答案2

如何使用参数定义引用块,例如,使用 \cleardoublepage {...}

\def\cleardoublepage#1#2{
\clearpage\if@twoside%
\ifodd\c@page\else
\vspace*{\fill}
\settowidth\longest{\itshape ``but there is a miraculous     feeling.''}
\hfill
\begin{center}
\parbox{\longest}{%
\raggedright{\itshape%
``%
#1''\par\bigskip
}
\raggedleft\scshape{#2}\par%
}
\end{center}
\vspace{\fill}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi
}

然后,无论你喜欢什么,

\cleardoublepage{A very nice \\ citation \\ for the next \\ beautiful chapter.}{anonymous}

使用你的引号。当然,最长的行识别可能会有点混乱……这是一个严重的问题吗?

相关内容