我想在回忆录中添加一些诗歌的归属。下面的代码可以做到这一点,但会将归属与文本块的右侧对齐。我希望它们与诗句宽度的右侧对齐。
\documentclass[11pt]{memoir}
\newcommand{\attrib}[1]{%
\vskip2ex\nopagebreak{\raggedleft\footnotesize #1\par}}
\begin{document}
\settowidth{\versewidth}{``This boy is forest-born.''}
\begin{verse}[\versewidth]
``This boy is forest-born.''\\
\attrib{\textit{-- As You Like It}}
\end{verse}
\end{document}
答案1
此处的宏\attrib
可以采用可选参数来手动覆盖\versewidth
。将可选参数设置为\textwidth
将使归因相对于页面右对齐,如 MWE 中所示。
\documentclass[11pt]{memoir}
\newcommand{\attrib}[2][\versewidth]{%
\vskip2ex\nopagebreak{\raggedleft\footnotesize%
#2\hspace{\dimexpr.5\textwidth-.5\dimexpr#1}\mbox{}\par}}
\begin{document}
\settowidth{\versewidth}{``This boy is forest-born.''}
\begin{verse}[\versewidth]
``This boy is forest-born.''\\
\attrib{\textit{-- As You Like It}}
\end{verse}
\settowidth{\versewidth}{``This boy is forest-born blah blah.''}
\begin{verse}[\versewidth]
``This boy is forest-born blah blah.''\\
\attrib{\textit{-- As You Like It}}
\end{verse}
\settowidth{\versewidth}{``Override the default attib placement.''}
\begin{verse}[\versewidth]
``Override the default attib placement.''\\
\attrib[\textwidth]{\textit{-- As You Like It}}
\end{verse}
\end{document}