Is there any package for typesetting tangram figures in LaTeX? Example figures are:
(without showing the tans)
(showing the tans)
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityIs there any package for typesetting tangram figures in LaTeX? Example figures are:
(without showing the tans)
(showing the tans)
You don't say how you want to specify the tangram diagrams and without that it's tricky to know how best to answer your question. Having said that, I had occasion to want to make some diagrams myself and so am posting the code in the hope that it is somewhat helpful.
It uses TikZ and makes pics of the pieces. These can then be placed to form the diagram. The pics are simply shortcuts for the code to draw the shapes and don't have any fancy positioning syntax (such as "place the big triangle along the medium triangle") because I found it much easier to place the tiles using coordinates (albeit often relative ones) than positions along existing tiles. To allow for fancy positioning, it would probably be better to convert them to nodes. For what I was doing, that was more hassle than it was worth.
There are two main styles: tangram puzzle
and tangram solution
. The main difference is that the tangram solution
draws the edges of the tiles in white with a fairly thick line, thus outlining them.
\documentclass{article}
%\url{https://tex.stackexchange.com/q/407449/86}
\usepackage[scale=.8]{geometry}
\thispagestyle{empty}
\pagestyle{empty}
\usepackage{tikz}
\tikzset{
big triangle/.pic={
\path[pic actions] (0,0) -- (2,0) -- (2,2) -- cycle;
},
medium triangle/.pic={
\path[pic actions] (0,0) -- (1,1) -- (2,0) -- cycle;
},
square/.pic={
\path[pic actions] (0,0) -- (1,0) -- (1,1) -- (0,1) -- cycle;
},
small triangle/.pic={
\path[pic actions] (0,0) -- (1,0) -- (1,1) -- cycle;
},
parallelogram/.pic={
\path[pic actions] (0,0) -- (1,0) -- (2,1) -- (1,1) -- cycle;
}
}
\tikzset{
tangram puzzle/.style={
fill=black,
draw=black
},
tangram solution/.style={
fill=black,
draw=white,
line width=1mm
},
tangram/.style={
transform shape,
%tangram puzzle
tangram solution
}
}
\begin{document}
\centering
\vspace*{\fill}
\begin{tikzpicture}[scale=4]
\pic[tangram] at (0,0) {big triangle};
\pic[tangram,rotate=-90] at (2,2) {big triangle};
\pic[tangram,rotate=-90] at (2,0) {square};
\pic[tangram,rotate=180] at (4,0) {small triangle};
\pic[tangram,rotate=90] at (2,-1) {small triangle};
\pic[tangram,xscale=-1] at (2,-1) {parallelogram};
\pic[tangram,rotate=180] at (3,-1) {medium triangle};
\end{tikzpicture}
\vspace*{\fill}
\newpage
\vspace*{\fill}
\begin{tikzpicture}[scale=3.5]
\path (0,-1) pic[tangram] {small triangle}
++(1,0) pic[tangram] {square}
++(1,1) pic[tangram,rotate=-45,yscale=-1] {big triangle}
++(-45:2) pic[tangram,rotate=-135] {big triangle}
+({-sqrt(2)},0) pic[tangram,rotate=-135] {parallelogram}
++(-2,{-2*sqrt(2)}) pic[tangram] {medium triangle}
++(2,1) pic[tangram,rotate=-90] {small triangle}
;
\end{tikzpicture}
\vspace*{\fill}
\newpage
\vspace*{\fill}
\begin{tikzpicture}[scale=3.5]
\path (6,0) pic[tangram,rotate=45] {small triangle}
pic[tangram,rotate=-45] {square}
pic[tangram,rotate=-45,yscale=-1] {big triangle}
++(-45:2) pic[tangram,rotate=-135] {big triangle}
+({-sqrt(2)},0) pic[tangram,rotate=-135] {parallelogram}
++(-2,{-2*sqrt(2)}) pic[tangram] {medium triangle}
++(2,1) pic[tangram,rotate=-90] {small triangle}
;
\end{tikzpicture}
\vspace*{\fill}
\newpage
\vspace*{\fill}
\begin{tikzpicture}[scale=3.5]
\path (9,{1/sqrt(2)}) pic[tangram,rotate=-45] {small triangle}
++(-45:1) pic[tangram,rotate=-45] {square}
pic[tangram,rotate=-45,yscale=-1] {big triangle}
++(-45:2) pic[tangram,rotate=-135] {big triangle}
+({-sqrt(2)},0) pic[tangram,rotate=-135] {parallelogram}
++(-2,{-2*sqrt(2)}) pic[tangram] {medium triangle}
++(2,1) pic[tangram,rotate=-90] {small triangle}
;
\end{tikzpicture}
\vspace*{\fill}
\newpage
\vspace*{\fill}
\begin{tikzpicture}[scale=3.5]
\path (0,0) pic[tangram] {big triangle}
++(2,2) pic[tangram,rotate=180] {big triangle}
++(0,1) pic[tangram,rotate=-90] {small triangle}
++(-1,-1) pic[tangram] {square}
++(-1,0) pic[tangram] {small triangle}
++(-1,0) pic[tangram] {parallelogram}
++(1,1) pic[tangram] {medium triangle}
;
\end{tikzpicture}
\vspace*{\fill}
\newpage
\vspace*{\fill}
\begin{tikzpicture}[scale=3,rotate=90]
\path (0,0) pic[tangram,rotate=-90] {small triangle}
++(-1,-1) pic[tangram] {square}
++(-1,0) pic[tangram] {small triangle}
++(-1,0) pic[tangram] {parallelogram}
++(1,1) pic[tangram] {medium triangle}
++({-1-sqrt(2)},{-1+sqrt(2)}) pic[tangram,rotate=-45] {big triangle}
++(4,0) pic[tangram,rotate=-45] {big triangle}
;
\end{tikzpicture}
\vspace*{\fill}
\newpage
\vspace*{\fill}
\begin{tikzpicture}[scale=3]
\path (0,0) pic[tangram,rotate=180] {medium triangle}
++(-1,-1) pic[tangram] {parallelogram}
++(1,0) pic[tangram] {small triangle}
++(1,0) pic[tangram] {square}
++(2,1) pic[tangram,rotate=180] {small triangle}
++(-2.5,.1) pic[tangram,rotate=80] {big triangle}
++(80:4)
++(170:2) pic[tangram,rotate=-100] {big triangle}
;
\end{tikzpicture}
\end{document}
And here's one of the outputs: