使用自定义新命令时遇到困难

使用自定义新命令时遇到困难

我正在尝试将以下内容转换为自定义新命令的代码,该命令采用三个参数:quote、author、profession。手动代码如下:

\documentclass[a4paper,12pt,twoside]{book}
\usepackage{blindtext}
\usepackage{geometry}
\geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, shadows}

\usepackage{tocbibind}
\usepackage{fontspec}
\newfontfamily\trfamily{JennaSue.ttf}

\begin{document}
\chapter{Introduction}

\trfamily
\begin{flushright}
\begin{LARGE}
\reflectbox{"}It is the unknown that excites the ardor of scholars, who,\\ in the known alone, would shrivel up with boredom."
\end{LARGE}
\end{flushright}
\rmfamily

\begin{flushright}
\begin{footnotesize}
\textit{\textsc{ - Wallace Stevens}}\\
\textit{American Poet}
\end{footnotesize}
\end{flushright}
\vspace{2cm}

\end{document}

输出为:

在此处输入图片描述

我已尝试过:

\newcommand\quotation[3]{\trfamily\begin{flushright}\begin{LARGE}\reflectbox{"}{#1}\end{LARGE}\end{flushright}\rmfamily\begin{footnotesize}\textit{\textsc{ - {#2}}}\\\textit{{#3}}\end{footnotesize}\end{flushright}\vspace{2cm}}

答案1

  • 正如 Harald Hanche-Olsen 所建议的那样他的评论字体大小命令类似于\LARGE开关,不接受参数。

  • 然后\begin{flushright}失踪

  • 无需包装#1{}

  • 缺少结束引号


\documentclass[a4paper,12pt,twoside]{book}
\usepackage{blindtext}
\usepackage{geometry}
\geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, shadows}

\usepackage{tocbibind}
\usepackage{fontspec}
\newfontfamily\trfamily{JennaSue.ttf}

\newcommand{\quatation}[3]{%
\trfamily
\begin{flushright}
\LARGE \reflectbox{"}~#1''
\end{flushright}
\rmfamily

\begin{flushright}
\footnotesize
\textit{\textsc{ - #2}}\\
\textit{#3}
\end{flushright}
\vspace{2cm}
}

\begin{document}
\chapter{Introduction}

\quatation{It is the unknown that excites the ardor of scholars, who,\\ in the known alone, would shrivel up with boredom.}{Wallace Stevens}{American Poet}


\end{document}

答案2

您可以使用包轻松获取命令epigraph:我定义了一个\myepigraph命令,但\epigraph带有自定义参数。我还在您的中添加了一个细空格\reflectbox

\documentclass[a4paper,12pt,twoside]{book}

\usepackage{blindtext}
\usepackage{geometry}
\geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, shadows}

\usepackage{tocbibind}
\usepackage{fontspec}
\newfontfamily\trfamily{JennaSue.ttf}

\usepackage{epigraph}
\setlength{\epigraphwidth}{0.8\linewidth}
\setlength{\epigraphrule}{0pt}
%\renewcommand{\textflush}{\raggedleft}

\newcommand{\myepigraph}[2]{%
\setlength{\epigraphwidth}{0.8\linewidth}
\setlength{\epigraphrule}{0pt}
\setlength{\afterepigraphskip}{35pt}
\epigraph{\raggedleft\trfamily{\LARGE #1}\medskip}{\footnotesize\itshape #2}
}
\begin{document}

\chapter{Introduction}

\myepigraph{\reflectbox{\,"}It is the unknown that excites the ardor of scholars, who,\\ in the known alone, would shrivel up with boredom."}{\textsc{– Wallace Stevens}\\American Poet}

\blindtext[1]

\end{document} 

在此处输入图片描述

相关内容