箱体溢流柱

箱体溢流柱

一切都与主题有关。我在一篇文章中使用了各种方框towcolumn,但只要方框内的文字足够长,方框就会愉快地延伸到另一列!

是否有一个“智能”框可以“跟随”文本,就像 URL 周围的蓝色框一样?示例文档:

\documentclass[10pt,twoside,twocolumn,english]{article} 
\begin{document}  
\fbox{Alpha particles (named after and denoted by the first letter in the
Greek alphabet) consist of two protons and two neutrons bound
together.
This means that an  particle is a helium nucleus. }
\end{document}

答案1

这对于评论来说太长了:我认为一张图片就足以说服你放弃这个项目。

在此处输入图片描述

结果无疑是糟糕的。


严肃地说,这里有一个以更好的方式构建某事物的简单方法。

\documentclass[10pt]{article}

\usepackage{lipsum} % for the mock text

\usepackage{mdframed}

\begin{document}

\lipsum[1]

\begin{mdframed}[
  leftmargin=\parindent,
  rightmargin=\parindent,
  skipabove=\topsep,
  skipbelow=\topsep
  ]
  \emph{Alpha particles} (named after
    and denoted by the first letter in the Greek
alphabet) consist of two protons and two neutrons bound
together. This means
that a particle is a helium nucleus.
\end{mdframed}

\lipsum[2]

\end{document}

在此处输入图片描述

答案2

这里有两种解决方案可以保留\fbox。要框起来的文本用 包裹\parbox以确保换行,并调整缩进。第一种方案保留文本的列线宽度。因此,这将导致 过满\hbox,您可能会介意,也可能不会介意。或者,可以调整 的宽度\parbox,使\fbox完全适合\linewidth,如右列所示。

在此处输入图片描述

代码

\documentclass[twocolumn]{article}
\raggedbottom       %don't stretch space between paragraphs to fill columns
\usepackage{lipsum}
\usepackage{calc}

\newlength\defaultparindent
\setlength{\defaultparindent}{\parindent}   %save default indentation   

\begin{document}
\section{Section}

\lipsum[75]
\vspace{\dimexpr.8pt+\fboxsep\relax}        %add interline space

%Version 1
{%group to keep \parindent change local
    \parindent-\fboxsep     %revert indentation due to \fbox frame space
    \indent%    
    \fbox{%
        \parbox{\linewidth}{%
        \parindent\defaultparindent%
        \indent Alpha particles (named after and denoted by the first letter in the Greek alphabet) consist of two protons and two neutrons bound
    together. This means that an  particle is a helium nucleus.}}
}%end parindent group

\vspace{\dimexpr.8pt+\fboxsep\relax}    

\lipsum[1]
\pagebreak
\lipsum[1]

\vspace{\dimexpr.8pt+\fboxsep\relax}

%Version 2
\noindent       
\fbox{%
    \parbox{\linewidth-2\fboxsep-1.6pt}{%
    \parindent\defaultparindent%
    \indent Alpha particles (named after and denoted by the first letter in the Greek alphabet) consist of two protons and two neutrons bound
together. This means that an  particle is a helium nucleus.}}

\vspace{\dimexpr.8pt+\fboxsep\relax}

\lipsum[75]     
  \end{document}

答案3

\documentclass{article}
\usepackage{soul}
\usepackage{color}
\begin{document}
This is \texthl{a very, very, very, very, in fact, an obscenely long
  and considerably friendly text}, my friend.
\end{document}

您会发现,用于文本突出显示的包的基本机制soul对于应该换行的带框文本也是必需的:大部分换行框由固定高度的上划线和下划线组成。实际上,我很难想象这种带有边框的结构在换行环境中看起来不错,但这听起来就是您想要的。当框不出现在中线而是作为自己的容器/块出现时,包framed将提供各种样式。

答案4

我能找到的最接近的东西是乌尔里克's varbox(使用\columnwidth而不是\linewidth+一些定制以获得更紧密的盒子):

\makeatletter
\newcommand{\varbox}[1]{%
  \setlength{\@tempdima}{\dimexpr\columnwidth\relax}%
  \sbox{\@tempboxa}{#1}%
  \ifdim\wd\@tempboxa>\@tempdima
    \begingroup\fboxsep=0.6mm
      \fbox{\parbox{\@tempdima}{\strut #1}}%
    \endgroup
    \vspace{\dimexpr-2pt\relax}
  \else
    \begingroup\fboxsep=0.4mm
      \fbox{\strut #1} 
    \endgroup
  \fi}
\makeatother

相关内容