删除脚注环境前后不需要的垂直空间

删除脚注环境前后不需要的垂直空间

我正在尝试为悬挂脚注中的(左)缩进块创建自己的环境,其中正常quote环境不起作用,它的左缩进与脚注的缩进相同,因此看不到它。我现在尝试使用 adjustwidth 环境来实现这一点,它可以按我想要的方式进行缩进,但如果脚注中它之前或之后没有任何内容,它会在环境之前和之后插入水平空格,环境quote似乎也有这种行为。

我尝试采用建议的解决方案这里,但\compress似乎没有做任何事情,并且环境后的负数\vspace会将下一行(如果有的话)拉到环境的最后一行。

\documentclass{memoir}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\setlength{\footmarkwidth}{\leftmargin}
\setlength{\footmarksep}{0em}
\footmarkstyle{#1\hfill}
\newenvironment{fnquote}[1][]{\compress\ifx\\#1\\\begin{adjustwidth}{1.5\leftmargin}{}\else\begin{adjustwidth}{1.5\leftmargin}{}[#1]\fi}{\end{adjustwidth}\vspace{-\lastskip}\vspace{-\baselineskip}\leavevmode}
\begin{document}
Some text\footnote{Enough text to be two lines in the footnote. Enough text to be two lines in the footnote. Enough text to be two lines in the footnote.
\begin{adjustwidth}{1.5\leftmargin}{}
And here we have a quote inside the footnote. With some text before or after it it looks fine, but ...
\end{adjustwidth}
Some text after the quote.
}
\footnote{
\begin{adjustwidth}{1.5\leftmargin}{}
If I have a footnote starting or ending with a quotation I get an empty line, before or after, which I don't want.
\end{adjustwidth}
}
\footnote{
\begin{fnquote}
If I have a footnote starting or ending with a quotation I get an empty line, before or after, which I don't want.
\end{fnquote}
And some more text here.
}
\footnote{Just another footnote.}
\end{document}

是否可以使用另一个开关来欺骗环境,让其认为脚注前后有一些文本?

答案1

我不确定这是否真的是你想要的:结果是错误的,没有人会理解为什么第二和第三个脚注中的文本向右移动。

\documentclass{memoir}

\setlength{\footmarkwidth}{\leftmargin}
\setlength{\footmarksep}{0em}
\footmarkstyle{#1\hfill}

\newenvironment{fnquote}
 {\par
  \setbox0=\lastbox \setbox2=\hbox{\unhcopy0}%
  \ifdim\wd2>\leftmargin \nointerlineskip\else\prevdepth=\dp\strutbox\fi\box0
  \vspace{-2.83337pt plus -1.41669pt minus -0.94446pt}%
  \ifdim\wd2>\leftmargin \else\vspace{-\baselineskip}\fi
  \begin{adjustwidth}{1.5\leftmargin}{}}
 {\end{adjustwidth}\vspace{-2.83337pt plus -1.41669pt minus -0.94446pt}}
\newenvironment{fnquote*}
 {\fnquote}{\endfnquote\vspace{-\baselineskip}}

\begin{document}
Some text\footnote{%
  Enough text to be two lines in the footnote. Enough text to be two 
  lines in the footnote. Enough text to be two lines in the footnote.
  \begin{fnquote}
    And here we have a quote inside the footnote. With some text before or after
    it it looks fine, but ...
  \end{fnquote}
  Some text after the quote.}
\footnote{%
  \begin{fnquote*}
  If I have a footnote starting or ending with a quotation I get an empty line,
  before or after, which I don't want.
  \end{fnquote*}
}
\footnote{%
  \begin{fnquote}
  If I have a footnote starting or ending with a quotation I get an empty line,
  before or after, which I don't want.
  \end{fnquote}
  And some more text here.
}
\footnote{Just another footnote.}
\end{document}

问题是,任何脚注在开头和结尾都有两个隐式支柱;当fnquote出现在开头时,它会执行\par,因此支柱本身会形成一个段落。同样,如果 后面没有文本fnquote,则最后一个支柱会自行形成一个段落。

我测量了最后一行排版,如果它长于\leftmargin,就意味着它有文本;否则我会备份必要的内容。

对于以脚注结尾的引文,必须使用fnquote*由基线跳过支持的不同环境。

在此处输入图片描述

相关内容