为什么 4 个 longfbox 配置中有 3 个不提供文本换行功能?

为什么 4 个 longfbox 配置中有 3 个不提供文本换行功能?

事实证明,该longfbox软件包非常有用,可以跨页面拆分长诗,这是我多年来一直在寻找的东西。longfbox然而,在 4 种配置中,有 3 种配置会导致长度超过页面宽度的文本无法正确换行。即使有这个限制,longfbox能够正确换行的单一配置也将在我的 LaTeX 项目和文档中成为有价值的补充。

在对我的 LaTeX 项目和文档进行全面更改以实现该longfbox软件包之前,我有两个问题:

  1. 我是否遗漏了longfboxLaTeX 代码中的某些内容,导致文本无法在 4 种配置中的 3 种配置中换行?(请参阅下面的 MWE。)
  2. longfbox2020 年 11 月 17 日, SE 上记录了该软件包中的一个 LaTeX 错误,网址为longfbox 包错误。该错误尚未在软件包本身中得到纠正longfbox。鉴于自 2015 年 12 月 5 日首次发布该软件包以来(7 年)一直处于停顿状态,并且缺乏针对已知错误的更新,我想知道该longfbox软件包是否仍在维护?如果没有,我是否应该在将该软件包纳入longfbox我的整个 LaTeX 项目之前先看看是否有更新的替代软件包正在维护?
\documentclass{article}
\usepackage{longfbox}

% See 'Error with longfbox package' at \url{https://tex.stackexchange.com/questions/571207/error-with-longfbox-package}
\makeatletter
\newdimen\@tempdimd
\makeatother

% The longfbox \newfboxstyle+\lfbox macro combination does not wrap the text as it should. 
\newfboxstyle{textfbox}{
breakable=true,
border-width=0.4pt,
border-top-color=blue,
border-bottom-color=blue,
border-style={solid,none,solid,none},
padding={2pt,5pt},
margin={3pt,3pt,1cm,3pt},
width={\dimexpr\textwidth-14pt},
baseline-skip=true
}

% And this \mylbox+\lfbox macro combination doesn't seem to wrap the text as it should either.
\newcommand*{\mylbox}[1]{%
\lfbox[
breakable=true,
border-width=0.4pt,
border-top-color=blue,
border-bottom-color=blue,
border-style={solid,none,solid,none},
padding={2pt,5pt},
margin={3pt,3pt,1cm,3pt},
width={\dimexpr\textwidth-14pt},
baseline-skip=true
]
{#1}
}

\begin{document}

\noindent\lfbox[textfbox]{An \textbf{initial} \textsf{longfbox} configuration using \textbf{newfboxstyle}+\textbf{lfbox}. A longfbox can contain much longer content and will by default be as wide as the current line width.}

\noindent\mylbox{A \textbf{second} \textsf{longfbox} configuration using \textbf{mylbox}+\textbf{lfbox}. A longfbox can contain much longer content and will by default be as wide as the current line width.}

\fboxset{
breakable=true,
border-width=0.4pt,
border-top-color=blue,
border-bottom-color=blue,
border-style={solid,none,solid,none},
padding={2pt,5pt},
margin={3pt,3pt,1cm,3pt},
width={\dimexpr\textwidth-14pt},
baseline-skip=true
}

\noindent\lfbox{A \textbf{third} \textsf{longfbox} configuration using \textbf{fboxset}+\textbf{lfbox}. A longfbox can contain much longer content and will by default be as wide as the current line width.}

% But when using the \longfbox macro directly (without the \newfboxstyle+\lfbox or \mylbox+\lfbox combination macros), the text wraps as it should.
\begin{longfbox}[
breakable=true,
border-width=0.4pt,
border-top-color=blue,
border-bottom-color=blue,
border-style={solid,none,solid,none},
padding={2pt,5pt},
margin={3pt,3pt,1cm,3pt},
width={\dimexpr\textwidth-14pt},
baseline-skip=true
]
{A \textbf{final} \textsf{longfbox} configuration using just \textbf{longfbox} alone. A longfbox can contain much longer content and will by default be as wide as the current line width.}
\end{longfbox}

\end{document}

longfbox 包的 4 种配置的结果。

答案1

这是记录的行为,就在包概述的开头,它说

与常规命令一样\fbox,该\lfbox命令将内容设置在水平框中,并且内容不能拆分为多行

答案2

DIY 长框。(我不确定您是想减少文本的宽度还是增加规则的宽度。)

\documentclass{article}
\usepackage{xcolor}

\newenvironment{mybox}{\par\medskip{\color{blue}\hrule height0.4pt}%
  \leftskip=3pt
  \rightskip=3pt
  \parindent=0pt
  \strut\ignorespaces}{\strut
{\color{blue}\hrule height0.4pt}\medskip}
  
\begin{document}
%\noindent\rule{\textwidth}{43\baselineskip}% test page breaking

\begin{mybox}
A \textbf{final} \textsf{longfbox} configuration using just \textbf{longfbox} alone. A longfbox can contain much longer content and will by default be as wide as the current line width.
\end{mybox}

Some text after.
\end{document}

相关内容