tcolorbox 与 tikzpicture 中尴尬的垂直空间

tcolorbox 与 tikzpicture 中尴尬的垂直空间

刚开始玩 tikz 和 tkz-euclide。我希望这些定义和图表能够比两列更好地对齐...我们把 45-45-90 称为“三角形 A”,把 30-60-90 称为“三角形 B”。

“更好”可能看起来像:

  • 三角形 A 的顶点与“三角形 B”的顶点处于同一高度或者它们的底边处于同一高度。
  • 三角形 B 与其上方的段落之间没有太多空间。
  • 其他?

三角形 B 被故意旋转了。我尝试使用 \vspace 并以不同的方式旋转图形。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{etex,amsmath,amsfonts,amssymb,graphicx,flexisym,tcolorbox,setspace,scrextend,siunitx,multicol,tikz,tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc}
\usepackage[margin=1cm,bmargin=1.4cm]{geometry}

\newtcolorbox{mybox}[1][]{
  boxsep=3pt,
  code={\doublespacing},
  #1}

\begin{document}
\begin{mybox}
\begin{multicols}{2}
In a 45\si{\degree}-45\si{\degree}-90\si{\degree} triangle, the hypotenuse is $\sqrt{2}$ times as long as each leg.\\
\begin{tikzpicture}[rotate=135]
\tkzDefPoint(0,0){A}
\tkzDefPoint(3,0){B}
\tkzDrawTriangle[two angles = 45 and 45](A,B)
\tkzGetPoint{C}
\tkzMarkRightAngle[color=red](A,C,B)
\tkzLabelPoint[right](A){$A$}
\tkzLabelPoint[above](B){$B$}
\tkzLabelPoint[left](C){$C$}
\tkzLabelAngle[pos=0.8](C,B,A){45\si{\degree}}
\tkzLabelAngle[pos=0.75](B,A,C){45\si{\degree}}
\tkzLabelSegment[auto](B,A){$x\sqrt{2}$}
\tkzLabelSegment[auto](C,B){$x$}
\tkzLabelSegment[auto](A,C){$x$}
\end{tikzpicture}\\ \newpage
In a 30\si{\degree}-60\si{\degree}-90\si{\degree} triangle, the hypotenuse is twice as long as the shorter leg, and the longer leg is $\sqrt{3}$ times as long as the shorter leg.\\ 
\begin{tikzpicture}[rotate=180]
\tkzDefPoint(0,0){A}
\tkzDefPoint(3,0){B}
\tkzDrawTriangle[school](B,A)
\tkzGetPoint{C}
\tkzMarkRightAngle[color=red](B,A,C)
\tkzLabelPoint[right](A){$A$}
\tkzLabelPoint[left](B){$B$}
\tkzLabelPoint[above](C){$C$}
\tkzLabelAngle[pos=-1](C,B,A){30\si{\degree}}
\tkzLabelAngle[pos=0.6](A,C,B){60\si{\degree}}
\tkzLabelSegment[auto,swap](B,A){$x\sqrt{3}$}
\tkzLabelSegment[auto,swap](C,B){$2x$}
\tkzLabelSegment[auto,swap](A,C){$x$}
\end{tikzpicture}
\end{multicols}
\end{mybox}
\end{document}

两个三角形及其对齐问题

答案1

tkz-euclide 在其某些构造中使用三角形外部的控制点,从而扩大了边界框。在这种情况下,\tkzDrawTriangle[school](B,A)如果您使用overlay,边界框会变小:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{etex,amsmath,amsfonts,amssymb,graphicx,flexisym,tcolorbox,setspace,scrextend,siunitx,multicol,tikz,tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc,backgrounds}
\usepackage[margin=1cm,bmargin=1.4cm]{geometry}

\newtcolorbox{mybox}[1][]{
  boxsep=3pt,
  code={\doublespacing},
  #1}

\begin{document}
\begin{mybox}
\begin{multicols}{2}
In a 45\si{\degree}-45\si{\degree}-90\si{\degree} triangle, the hypotenuse is $\sqrt{2}$ times as long as each leg.\\
\begin{tikzpicture}[rotate=135,show background rectangle]
\tkzDefPoint(0,0){A}
\tkzDefPoint(3,0){B}
\tkzDrawTriangle[two angles = 45 and 45](A,B)
\tkzGetPoint{C}
\tkzMarkRightAngle[color=red](A,C,B)
\tkzLabelPoint[right](A){$A$}
\tkzLabelPoint[above](B){$B$}
\tkzLabelPoint[left](C){$C$}
\tkzLabelAngle[pos=0.8](C,B,A){45\si{\degree}}
\tkzLabelAngle[pos=0.75](B,A,C){45\si{\degree}}
\tkzLabelSegment[auto](B,A){$x\sqrt{2}$}
\tkzLabelSegment[auto](C,B){$x$}
\tkzLabelSegment[auto](A,C){$x$}
\end{tikzpicture}\\ \newpage
In a 30\si{\degree}-60\si{\degree}-90\si{\degree} triangle, the hypotenuse is twice as long as the shorter leg, and the longer leg is $\sqrt{3}$ times as long as the shorter leg.\\
\begin{tikzpicture}[rotate=180,show background rectangle]
\tkzDefPoint(0,0){A}
\tkzDefPoint(3,0){B}
\tkzDrawTriangle[school,overlay](B,A)%overlay
\tkzGetPoint{C}
\tkzMarkRightAngle[color=red](B,A,C)
\tkzLabelPoint[right](A){$A$}
\tkzLabelPoint[left](B){$B$}
\tkzLabelPoint[above](C){$C$}
\tkzLabelAngle[pos=-1](C,B,A){30\si{\degree}}
\tkzLabelAngle[pos=0.6](A,C,B){60\si{\degree}}
\tkzLabelSegment[auto,swap](B,A){$x\sqrt{3}$}
\tkzLabelSegment[auto,swap](C,B){$2x$}
\tkzLabelSegment[auto,swap](A,C){$x$}
\end{tikzpicture}
\end{multicols}
\end{mybox}
\end{document}

在此处输入图片描述

相关内容