修正的布尔巴基问题

修正的布尔巴基问题

专家包中有一个很好的宏\trailingcitation,如果有空格,它会在同一行的右边距排版引用,如果没有空格,它会在行的右边刷新引用(下面是前两个示例,使用了简化版本\trailingcitation)。不幸的是,这个宏无法处理长度超过一行的引用(第三个示例)。

我尝试使用彼得·威尔逊的\atright,但它将尽可能少的引用文本放在第一行(第四个示例)。

我想要的是,如果引文长度超过一行,则从新行开始,并向右对齐(或者,理想情况下,两端对齐,但最后一行与右侧对齐,而不是左侧边距)(第五个示例)。我该如何实现这一点?


在此处输入图片描述

\documentclass[draft]{article}

\usepackage[a4paper,margin=5cm]{geometry}
\usepackage{parskip}

\def\trailingcitation#1{% adapted from expex
   \hskip 1.5em plus 1fill
   \penalty100\null\nobreak \hskip 0pt plus 1fill
   \hbox{#1}}

\newcommand*{\atright}[1]{{%
  \unskip\nobreak\hfil\penalty50
  \hskip2em\hbox{}\nobreak\hfil#1
  \parfillskip=0pt\finalhyphendemerits=0\par}}

\begin{document}

A short quote gets a citation on the same line.
\trailingcitation{(Smith 2015)}

When the citation does not fit on the same line, a new line is used.
\trailingcitation{(Smith 2015)}

Due to \verb$\hbox$, long citations cause an overfull hbox.
\trailingcitation{(Author, \textit{Some very long title of a secondary source}, in citation by Smith 2015)}

\verb$\atright$ will make the first line as short as possible:
\atright{(Author, \textit{Some very long title of a secondary source}, in citation by Smith 2015)}

Whereas I want something like this (but only if it does not fit on the same line):\par\vspace{-1ex}
{\raggedleft (Author, \textit{Some very long title of a secondary source}, in citation by Smith 2015)\par}

\end{document}

答案1

在此处输入图片描述

\documentclass[draft]{article}

\usepackage[a4paper,margin=5cm]{geometry}
\usepackage{parskip}

\def\trailingcitation#1{% adapted from expex
   \unskip
   \hskip 1.5em plus 1fill
   \penalty100\null\nobreak \hskip 0pt plus 1fill
   \discretionary
   {}%
   {\vtop{%
  % shorter line (if you like)
  \leftskip 20pt
  #1\par
  % reset last line flush right
  \setbox0\lastbox
  \nointerlineskip
  \hbox to \hsize{\hfill\unhbox0\unskip\unskip}}%
    }%
   {\hbox{#1}}%
}

\begin{document}

A short quote gets a citation on the same line.
\trailingcitation{(Smith 2015)}

When the citation does not fit on the same line, a new line is used.
\trailingcitation{(Smith 2015)}

Due to \verb$\hbox$, long citations cause an overfull hbox.
\trailingcitation{(Author, \textit{Some very long title of a secondary source}, in citation by Smith 2015)}


\end{document}

在列表和 ExPex 示例中,可用的水平空间有限。需要\vtop设置为\hsize=\linewidth,ExPex 示例需要设置为剩余宽度可以计算。以下内容在 ExPex 示例和列表中均有效。它还使用 ExPex 的mincitesepeverytrailingcitation,为了简单起见,它们已从问题的 MWE 中删除:

在此处输入图片描述

\documentclass[draft]{article}

\usepackage[a4paper,margin=5cm]{geometry}
\usepackage{expex}

% Alan Munn's method to get remaining space in expex examples, https://tex.stackexchange.com/a/376534:
\usepackage{calc}
\usepackage{etoolbox}
\newlength{\remaining}
\newcommand{\remainpex}{%
   \setlength{\remaining}{\linewidth-\lingtextoffset-\linglabelwidth-
      \lingnumoffset-\linglabeloffset-\widthof{\exnoprint}}%
}
\newcommand{\remainex}{%
   \setlength{\remaining}{\linewidth-\lingnumoffset-
      \lingtextoffset-\widthof{\exnoprint}}%
}

% We also need to know whether we are in an example or not:
\newif\ifinex \inexfalse
\pretocmd{\pex}{\remainpex\inextrue}{}{}
\pretocmd{\ex}{\remainex\inextrue}{}{}
\apptocmd{\xe}{\inexfalse}{}{}

\makeatletter
\def\trailingcitation#1{% adapted from expex
   \unskip
   \hskip\ling@mincitesep plus 1fill
   \penalty100\null\nobreak \hskip 0pt plus 1fill
   \discretionary
   {}%
   {\vtop{%
  \hsize=\ifinex\remaining\else\linewidth\fi
  % shorter line (if you like)
  \leftskip 20pt
  \ling@everytrailingcitation #1\par
  % reset last line flush right
  \setbox0\lastbox
  \nointerlineskip
  \hbox to \hsize{\hfill\unhbox0\unskip\unskip}}%
    }%
   {\hbox{#1}}%
}
\makeatother

\begin{document}

\ex
  Due to \verb$\hbox$, long citations cause an overfull hbox.
  \trailingcitation{(Author, \textit{Some very long title of a secondary source}, in citation by Smith 2015)}
\xe

\pex
\a
  Due to \verb$\hbox$, long citations cause an overfull hbox.
  \trailingcitation{(Author, \textit{Some very long title of a secondary source}, in citation by Smith 2015)}
\xe

\begin{itemize}
  \item
    Due to \verb$\hbox$, long citations cause an overfull hbox.
    \trailingcitation{(Author, \textit{Some very long title of a secondary source}, in citation by Smith 2015)}
\end{itemize}

\end{document}

相关内容