我已经问了一些问题,我不知道自己是否太愚蠢了。
页面上的height fill
最后一个选项有一个不错的选择 。tcolorbox
是否可以将height fill
选项设置为最后一个tcbraster
而不是最后一个框?在我的情况下,只有两个相邻的框。唯一的解决方案是尝试像 [tcolorbox:高度填充页面中间?
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{tikzscale}
\begin{filecontents}{tikzimage.tikz}
\begin{tikzpicture}
\begin{axis}[xlabel=time,ylabel=value]
\addplot{x^2};
\end{axis}
\end{tikzpicture}
\end{filecontents}
\makeatletter
\tcbset{%
remember height/.style={before upper={%
\iftcb@fixedheight%
\tcbdimto#1{\kvtcb@top@rule@stand+\kvtcb@bottom@rule@stand+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom}%
\iftcb@hasTitle%
\tcbdimto#1{#1+\ht\tcb@titlebox+\dp\tcb@titlebox+\kvtcb@title@rule+\kvtcb@boxsep*2+\kvtcb@toptitle+\kvtcb@bottomtitle}%
\fi%
\tcbdimto#1{\kvtcb@height@fixed-#1}%
\else%
\tcbdimto#1{4cm}% fallback
\fi%
}},
}
\makeatother
\begin{document}
\begin{tcolorbox}
a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a
\end{tcolorbox}
\begin{tcolorbox}
b\\b\\b\\b\\b
\end{tcolorbox}
\begin{tcbraster}[%
raster columns=2,
raster rows=1,
% height fill,% this does not work :-(
height=4cm, % want to have height=\vfill
]
\begin{tcolorbox}[%
equal height group=mybox,
title={box 1\\line two},remember height=\myheight]
\includegraphics[width=\linewidth,height=\myheight]{tikzimage.tikz}
\end{tcolorbox}
\begin{tcolorbox}[equal height group=mybox]
This box and the box on the left is extendet to fill the page.
\end{tcolorbox}
\end{tcbraster}
\end{document}
@Thomas F. Sturm
我希望这是我的最后一个问题,抱歉,非常感谢您抽出时间!
答案1
tcolorbox
使用版本可以得到新的答案3.90 (2016/02/29)
。现在,height fill
也适用于栅格,并且可以通过以下方式获得固定高度框的文本高度\tcbtextheight
:
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{tikzscale}
\begin{filecontents}{tikzimage.tikz}
\begin{tikzpicture}
\begin{axis}[xlabel=time,ylabel=value]
\addplot{x^2};
\end{axis}
\end{tikzpicture}
\end{filecontents}
\begin{document}
\begin{tcolorbox}
a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a
\end{tcolorbox}
\begin{tcolorbox}
b\\b\\b\\b\\b
\end{tcolorbox}
\begin{tcbraster}
\begin{tcolorbox}[height fill,title={box 1\\line two}]
\includegraphics[width=\linewidth,height=\tcbtextheight]{tikzimage.tikz}
\end{tcolorbox}
\begin{tcolorbox}[height fill]
This box and the box on the left is extendet to fill the page.
\end{tcolorbox}
\end{tcbraster}
\end{document}
答案2
以下信息或许能帮到你:如何定义图形大小以使其占据页面的剩余部分?
只需将其放入序言中:
\newcommand\measurepage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
用作\measurepage
页面其余部分的长度。这样您就可以用内容填充页面的其余部分,例如:
\includegraphics[height=\measurepage,width=\textwidth]{cow}
就我而言:
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{tikzscale}
\newcommand\measurepage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
\begin{filecontents}{tikzimage.tikz}
\begin{tikzpicture}
\begin{axis}[xlabel=time,ylabel=value]
\addplot{x^2};
\end{axis}
\end{tikzpicture}
\end{filecontents}
\makeatletter
\tcbset{%
remember height/.style={before upper={%
\iftcb@fixedheight%
\tcbdimto#1{\kvtcb@top@rule@stand+\kvtcb@bottom@rule@stand+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom}%
\iftcb@hasTitle%
\tcbdimto#1{#1+\ht\tcb@titlebox+\dp\tcb@titlebox+\kvtcb@title@rule+\kvtcb@boxsep*2+\kvtcb@toptitle+\kvtcb@bottomtitle}%
\fi%
\tcbdimto#1{\kvtcb@height@fixed-#1}%
\else%
\tcbdimto#1{4cm}% fallback
\fi%
}},
}
\makeatother
\begin{document}
\begin{tcolorbox}
a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a
\end{tcolorbox}
\begin{tcolorbox}
b\\b\\b\\b\\b
\end{tcolorbox}
\begin{tcbraster}[%
raster columns=2,
raster rows=1,
% height fill,% this does not work :-(
height=\measurepage, % want to have height=\vfill
]
\begin{tcolorbox}[%
equal height group=mybox,
title={box 1\\line two},remember height=\myheight]
\includegraphics[width=\linewidth,height=\myheight]{tikzimage.tikz}
\end{tcolorbox}
\begin{tcolorbox}[equal height group=mybox]
This box and the box on the left is extendet to fill the page.
\end{tcolorbox}
\end{tcbraster}
\end{document}
使用它需要您自担风险。这可能不太可靠。但至少在这里它是有效的。
编辑:不适用于\usetikzlibrary{external}
!:-(