我无法使用此代码来适应紧密的盒子:
\begin{framed}
\begin{flushleft}
\# Description of the data \\
summary(training) \end{flushleft}
\end{framed}
我也没法跳过这些行。
有人能帮忙吗?谢谢
答案1
也许您正在尝试输入某种代码,在这种情况下您应该使用listings
或tcblisting
(来自tcolorbox
)
这是一个选项:
\documentclass{article}
\usepackage{varwidth}
\begin{document}
\noindent
{%%<-- begin a group to make \fboxsep=0pt local
\fboxsep=0pt
\fbox{%
\begin{varwidth}{\textwidth}
\# Description of the data \\
summary(training)
\end{varwidth}
}
}%%<-- end group
\end{document}
其他:
\documentclass{article}
\begin{document}
\noindent
\begin{tabular}{|@{}l@{}|}\hline
\# Description of the data\\
\\
summary(training)\\\hline
\end{tabular}
\end{document}
和tcolorbox
\documentclass{article}
\usepackage{tcolorbox,varwidth}
\newtcbox{\tightbox}{colback=white,arc=0pt,boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt,
boxrule=0.5pt,varwidth upper}
% or simpler with same effect
% \newtcbox{\tightbox}{colback=white,size=tight,varwidth upper} %% thanks to Ignasi.
\begin{document}
\tightbox{
\# Description of the data\\
summary(training)
}
\end{document}
tcblistings
为了完整起见,这是一个示例
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{listings,skins}
\tcbset{enhanced,width=4.4cm,colframe=black, listing only, colback=white,arc=0pt,boxsep=0pt,left=0pt,right=0pt,top=0pt,bottom=0pt,
boxrule=0.5pt}
\begin{document}
\begin{tcblisting}{}
\# Description of the data
summary(training)
\end{tcblisting}
\end{document}
您必须自己调整宽度。