Skip to main content
added 1234 characters in body
Source Link
Thomas F. Sturm
  • 25.9k
  • 1
  • 54
  • 90

With tcolorbox version 3.90 (2016/02/29), there is a property \tcbtextheight which holds the text height of a fixed height box (inspired by this question!). With it, the solution is short:

\documentclass{article} \usepackage{pgfplots} \usepackage{tikzscale} \usepackage{tcolorbox} \tcbuselibrary{raster} \begin{filecontents}{tikzimage.tikz} \begin{tikzpicture} \begin{axis}[xlabel=time,ylabel=value] \addplot{x^2}; \end{axis} \end{tikzpicture} \end{filecontents} \begin{document} \begin{tcbraster}[% raster columns=2, raster rows=2, raster height=\textheight, ] \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}[title={box 1\\line two}] \includegraphics[% width=\linewidth, height=\tcbtextheight, ]{tikzimage.tikz} \end{tcolorbox} \end{tcbraster} \end{document} 

Old Answer (valid for tcolorbox before version 3.90):

In my answer, a new option remember height is constructed which saves the actual inner height into a chosen macro at the begin of the upper box. The following example uses \myheight which can be used to scale the included image.

In my answer, a new option remember height is constructed which saves the actual inner height into a chosen macro at the begin of the upper box. The following example uses \myheight which can be used to scale the included image.

With tcolorbox version 3.90 (2016/02/29), there is a property \tcbtextheight which holds the text height of a fixed height box (inspired by this question!). With it, the solution is short:

\documentclass{article} \usepackage{pgfplots} \usepackage{tikzscale} \usepackage{tcolorbox} \tcbuselibrary{raster} \begin{filecontents}{tikzimage.tikz} \begin{tikzpicture} \begin{axis}[xlabel=time,ylabel=value] \addplot{x^2}; \end{axis} \end{tikzpicture} \end{filecontents} \begin{document} \begin{tcbraster}[% raster columns=2, raster rows=2, raster height=\textheight, ] \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}[title={box 1\\line two}] \includegraphics[% width=\linewidth, height=\tcbtextheight, ]{tikzimage.tikz} \end{tcolorbox} \end{tcbraster} \end{document} 

Old Answer (valid for tcolorbox before version 3.90):

In my answer, a new option remember height is constructed which saves the actual inner height into a chosen macro at the begin of the upper box. The following example uses \myheight which can be used to scale the included image.

Source Link
Thomas F. Sturm
  • 25.9k
  • 1
  • 54
  • 90

In my answer, a new option remember height is constructed which saves the actual inner height into a chosen macro at the begin of the upper box. The following example uses \myheight which can be used to scale the included image.

\documentclass{article} \usepackage{pgfplots} \usepackage{tikzscale} \usepackage{tcolorbox} \tcbuselibrary{raster} \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{tcbraster}[% raster columns=2, raster rows=2, raster height=\textheight, ] \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}\end{tcolorbox} \begin{tcolorbox}[title={box 1\\line two},remember height=\myheight] \includegraphics[% width=\linewidth, height=\myheight, ]{tikzimage.tikz} \end{tcolorbox} \end{tcbraster} \end{document} 

enter image description here

Maybe, such on option or something similar whould not be bad as an official option?