2

Just started playing around with tikz and tkz-euclide. I want these definitions and diagrams to align better than this in two columns... Let's call 45-45-90 "Triangle A" and 30-60-90 "Triangle B."

"Better" might look like:

  • The top of Triangle A is at the same height as the top of "Triangle B" or their bases are at the same height.
  • Triangle B doesn't have so much space between it and the paragraph above it.
  • other?

Triangle B has been rotated purposefully. I've tried working with \vspace and rotating the figures differently.

\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}

Two triangles and their alignment issues

Jenni
  • 145
  • With a recent TeX distribution, loading etex is neither needed nor recommended. I also have doubts about loading flexisym. – egreg Dec 15 '17 at 22:52
  • If I don't put etex there, I get a warning "/usr/share/texlive/texmf-dist/tex/latex/etex-pkg/etex.sty: Package etex Warning: Extended allocation already in use. (etex) etex.sty code will not be used. (etex) To force etex package to load, add (etex) \RequirePackage{etex} (etex) at the start of the document." – Jenni Dec 18 '17 at 15:21
  • No warning for me. Please, update your TeX distribution to begin with. – egreg Dec 18 '17 at 16:38
  • Sorry @egreg, I'm not sure what that means. I'm using overleaf.com, not anything downloaded to my computer. – Jenni Dec 18 '17 at 16:45
  • @egreg Jenni is right. tkz-base.sty uses \RequirePackage{etex} . After a few difficult years, I work again on my packages. A good thing is to replace the code by \ifx\e@alloc\@undefined \RequirePackage{etex}\fi. A next update will fix this. – Alain Matthes Jan 01 '18 at 20:58
  • @AlainMatthes Great news you're back to work with LaTeX! Happy new year! – egreg Jan 01 '18 at 21:07

1 Answers1

4

tkz-euclide uses for some of its constructions control points outside the triangles which enlarges the bounding box. In this case in \tkzDrawTriangle[school](B,A) If you use overlay there the bounding box is smaller:

\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}

enter image description here

Ulrike Fischer
  • 327,261
  • What exactly does overlay do? Great explanation otherwise, this is what I was looking for. – Jenni Dec 15 '17 at 21:31
  • 2
    See https://tex.stackexchange.com/questions/85836/tikz-ignore-one-path-in-bounding-box-calculation – Ulrike Fischer Dec 15 '17 at 21:35
  • There are other possibilities to control the bounding box. You can use \pgfresetboundingboxafter \tkzDrawTriangle. I don't know if there is something in my doc but it's a good idea to add some ideas to control the bounding box. You can find other examples on the site. – Alain Matthes Jan 01 '18 at 21:23