我想在回憶錄中加入一些詩的歸屬。下面的程式碼執行此操作,但將屬性刷新到文字區塊的右側。我希望它們與詩句寬度的右邊齊平。
\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}