\vspace{\stretch{1}} 在 mdframed 環境中無法運作的問題

\vspace{\stretch{1}} 在 mdframed 環境中無法運作的問題

我在 mdframed 環境中使用 \vspace{\stretch{1}} 時遇到問題。我試圖在框架內的定理之後添加一些垂直空間,但似乎 \vspace{\stretch{1}} 命令未按預期運行。

我知道我可以使用 \vspace{x cm} 但我不想使用它。我想均勻地劃分頁面。

我有

這是我所擁有的一個最小範例:

\documentclass{article}
\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{xcolor}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}

\begin{document}

\begin{mdframed}[
    linecolor=blue,
    linewidth=2pt,
    backgroundcolor=orange!20,
]
\begin{theorem}
  Some subtheorem.
\end{theorem}
\vspace{\stretch{1}}
\end{mdframed}

\end{document}

答案1

x\par\vfill x 這與小型頁面或 \parbox 中使用的問題相同。不適用於:

\fbox{\begin{minipage}{3cm} x\par\vfill x \end{minipage}} 

因為,好吧,你想填滿這個盒子,...但能填滿多少呢?該盒子沒有預先定義的高度。

它在正文中起作用,因為頁面有強制高度。只有當您將其拉伸到某物時,它才會拉伸。在小型頁面中,您可以固定框的高度:

\fbox{\begin{minipage}[c][3cm][c]{3cm} x\par\vfill x \end{minipage}} 

在此輸入影像描述

請注意,如果您使用 atcolorbox而不是 mdframed,則允許選擇固定高度,即使這樣也不起作用:

\begin{tcolorbox}[height=3cm]  x\par  \vfill x \end{tcolorbox}

(這不是一個錯誤,這是一個功能!)

我想均勻地劃分頁面

如果你想要相等的盒子,那麼你可以使用 tcolorbox 的光柵庫,因此每個盒子的高度由高度較大的盒子固定:

姆韋2

\documentclass[twocolumn]{article}
\usepackage[raster]{tcolorbox}
\begin{document}

\begin{tcbraster}[raster columns=1, size=small, title={\sffamily\bfseries Free  height box No. \thetcbrasternum}]
\begin{tcolorbox}First box\end{tcolorbox}
\begin{tcolorbox}Second box\end{tcolorbox}
\begin{tcolorbox}This is a box\\with a second line \\ with a third line \\ with a fourth line  \end{tcolorbox}
\begin{tcolorbox}Another box\end{tcolorbox}
\begin{tcolorbox}A box\par \vspace{.3 cm} again\end{tcolorbox}
\end{tcbraster}

\newpage

\begin{tcbraster}[raster columns=1, size=small, raster equal height,
size=small,colframe=red!50!black,colback=red!10!white,colbacktitle=red!50!white,coltitle=black,
title={\sffamily\bfseries Evenlized box No. \thetcbrasternum}]
\begin{tcolorbox}First box\end{tcolorbox}
\begin{tcolorbox}Second box\end{tcolorbox}
\begin{tcolorbox}This is a box\\with a second line \\ with a third line \\ with a fourth line  \end{tcolorbox}
\begin{tcolorbox}Another box\end{tcolorbox}
\begin{tcolorbox}A box\par \vspace{.3 cm} again\end{tcolorbox}
\end{tcbraster}
\end{document}

相關內容