0

I've generated the following code frome Geogebra and for some reason it's not working. I get tons of error messages in Overleaf and I feel kinda lost. Any insight about what might have gone wrong would be appreciated. This is the code that Geogebra made. First I wanted to make sure it works, and then tweak around the code a little bit for making it nicer, but i didn't get to do that.

\documentclass[10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{zzttqq}{rgb}{0.6,0.2,0.}
\definecolor{ffqqqq}{rgb}{1.,0.,0.}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw [color=cqcqcq,, xstep=1.0cm,ystep=1.0cm] (10.969178552918187,3.9448398510122127) grid (17.036551252400248,8.104667345732874);
\clip(10.969178552918187,3.9448398510122127) rectangle (17.036551252400248,8.104667345732874);
\fill[line width=2.4pt] (4.,8.) -- (5.,7.) -- (4.,6.) -- (5.,5.) -- (4.,4.) -- (6.,4.) -- (7.,3.) -- (8.,4.) -- (8.,8.) -- (7.,9.) -- (6.,8.) -- cycle;
\fill[line width=2.4pt] (12.,7.) -- (13.,8.) -- (15.,8.) -- (16.,7.) -- (16.,5.) -- (17.,4.) -- (11.,4.) -- (12.,5.) -- cycle;
\fill[line width=2.4pt,fill=black,fill opacity=0.10000000149011612] (5.,12.) -- (7.,13.) -- (8.,12.) -- (9.,12.) -- (9.,14.) -- (10.,15.) -- (9.,16.) -- (7.934442391472151,15.863351386094383) -- (6.934442391472151,14.863351386094383) -- (5.,16.) -- (5.,14.) -- (6.,13.) -- cycle;
\fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (12.,8.) -- (12.,7.) -- (13.,8.) -- cycle;
\fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (12.,5.) -- (12.,4.) -- (11.,4.) -- cycle;
\fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (16.,5.) -- (16.,4.) -- (17.,4.) -- cycle;
\fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (16.,7.) -- (16.,8.) -- (15.,8.) -- cycle;
\draw [line width=2.4pt] (4.,8.)-- (5.,7.);
\draw [line width=2.4pt] (5.,7.)-- (4.,6.);
\draw [line width=2.4pt] (4.,6.)-- (5.,5.);
\draw [line width=2.4pt] (5.,5.)-- (4.,4.);
\draw [line width=2.4pt] (4.,4.)-- (6.,4.);
\draw [line width=2.4pt] (6.,4.)-- (7.,3.);
\draw [line width=2.4pt] (7.,3.)-- (8.,4.);
\draw [line width=2.4pt] (8.,4.)-- (8.,8.);
\draw [line width=2.4pt] (8.,8.)-- (7.,9.);
\draw [line width=2.4pt] (7.,9.)-- (6.,8.);
\draw [line width=2.4pt] (6.,8.)-- (4.,8.);
\draw [line width=2.4pt] (12.,7.)-- (13.,8.);
\draw [line width=2.4pt] (13.,8.)-- (15.,8.);
\draw [line width=2.4pt] (15.,8.)-- (16.,7.);
\draw [line width=2.4pt] (16.,7.)-- (16.,5.);
\draw [line width=2.4pt] (16.,5.)-- (17.,4.);
\draw [line width=2.4pt] (17.,4.)-- (11.,4.);
\draw [line width=2.4pt] (11.,4.)-- (12.,5.);
\draw [line width=2.4pt] (12.,5.)-- (12.,7.);
\draw [line width=2.4pt] (5.,12.)-- (7.,13.);
\draw [line width=2.4pt] (7.,13.)-- (8.,12.);
\draw [line width=2.4pt] (8.,12.)-- (9.,12.);
\draw [line width=2.4pt] (9.,12.)-- (9.,14.);
\draw [line width=2.4pt] (9.,14.)-- (10.,15.);
\draw [line width=2.4pt] (10.,15.)-- (9.,16.);
\draw [line width=2.4pt] (9.,16.)-- (7.934442391472151,15.863351386094383);
\draw [line width=2.4pt] (7.934442391472151,15.863351386094383)-- (6.934442391472151,14.863351386094383);
\draw [line width=2.4pt] (6.934442391472151,14.863351386094383)-- (5.,16.);
\draw [line width=2.4pt] (5.,16.)-- (5.,14.);
\draw [line width=2.4pt] (5.,14.)-- (6.,13.);
\draw [line width=2.4pt] (6.,13.)-- (5.,12.);
\draw [line width=2.4pt,color=ffqqqq] (6.934442391472151,14.863351386094385)-- (9.,16.);
\draw [line width=2.4pt,color=ffqqqq] (5.,14.)-- (5.,12.);
\draw [line width=2.4pt,color=ffqqqq] (5.,12.)-- (8.,12.);
\draw [line width=2.4pt,color=ffqqqq] (9.,14.)-- (9.,16.);
\draw (6.912772183756885,16.412831099000936) node[anchor=north west] {\textbf{T_1}};
\draw (9.19952818223592,15.068356466729343) node[anchor=north west] {\textbf{T_2}};
\draw (6.614000043252086,12.390898438359413) node[anchor=north west] {\textbf{T_1}};
\draw (5.131630576901355,13.045898900235319) node[anchor=north west] {\textbf{T_2}};
\draw [line width=2.pt,color=ffqqqq] (6.,8.)-- (8.,8.);
\draw [line width=2.pt,color=ffqqqq] (6.,4.)-- (8.,4.);
\draw [line width=2.pt,color=ffqqqq] (4.,4.)-- (4.,8.);
\draw (6.614000043252086,12.390898438359413) node[anchor=north west] {\textbf{T_1}};
\draw (6.614000043252086,12.390898438359413) node[anchor=north west] {\textbf{T_1}};
\draw (6.614000043252086,12.390898438359413) node[anchor=north west] {\textbf{T_1}};
\draw (4.108910557481083,5.025016051298794) node[anchor=north west] {\textbf{T_1}};
\draw (4.143384266000868,7.116421034832386) node[anchor=north west] {\textbf{T_1}};
\draw (6.809351058197531,8.403439486237673) node[anchor=north west] {\textbf{T_1}};
\draw (6.809351058197531,3.6230852381608907) node[anchor=north west] {\textbf{T_1}};
\draw [line width=2.pt,color=ffqqqq] (12.,7.)-- (12.,8.);
\draw [line width=2.pt,color=ffqqqq] (12.,8.)-- (13.,8.);
\draw [line width=2.pt,color=ffqqqq] (12.,5.)-- (12.,4.);
\draw [line width=2.pt,color=ffqqqq] (16.,5.)-- (16.,4.);
\draw [line width=2.pt,color=ffqqqq] (15.,8.)-- (16.,8.);
\draw [line width=2.pt,color=ffqqqq] (16.,8.)-- (16.,7.);
\end{tikzpicture}
\end{document}

Any help is appreciated. Thanks.

2
  • 1
    Once T_1 and T_2 are replaced by $T_1$ and $T_2$, it works for me. Although the result is quite strange.
    – Ignasi
    Jul 29, 2022 at 10:39
  • The funny thing is, that it does make it work, although the texts completley disappear. Yeah it looks funny partly due to the opacity, also it's a figure for some easy area manipulation tasks for 10-11 year old kids. Thanks for the help, it's not perfect yet but something i can work with at least! Jul 29, 2022 at 10:44

1 Answer 1

1

The underscore character is used to make subscripts, but it only works in math mode. That is why your code throws a missing $ error. So changing T_1 to $T_1$ as Ignasi suggested will fix that problem.

However, that change alone will make the code \textbf{$T_1$} which seems a bit odd to me, if the T should be bold then I would do $\mathbf{T}_1$. If not, use just $T_1$, without the \textbf{}.

The reason why those texts, and in fact most of the rest of the diagram, disappears, is the \clip instruction which is the second line in the tikzpicture environment. If you remove that line, you get this:

enter image description here

\documentclass[10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{zzttqq}{rgb}{0.6,0.2,0.}
\definecolor{ffqqqq}{rgb}{1.,0.,0.}
\definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw [color=cqcqcq,, xstep=1.0cm,ystep=1.0cm] (10.969178552918187,3.9448398510122127) grid (17.036551252400248,8.104667345732874);
%\clip(10.969178552918187,3.9448398510122127) rectangle (17.036551252400248,8.104667345732874);
\fill[line width=2.4pt] (4.,8.) -- (5.,7.) -- (4.,6.) -- (5.,5.) -- (4.,4.) -- (6.,4.) -- (7.,3.) -- (8.,4.) -- (8.,8.) -- (7.,9.) -- (6.,8.) -- cycle;
\fill[line width=2.4pt] (12.,7.) -- (13.,8.) -- (15.,8.) -- (16.,7.) -- (16.,5.) -- (17.,4.) -- (11.,4.) -- (12.,5.) -- cycle;
\fill[line width=2.4pt,fill=black,fill opacity=0.10000000149011612] (5.,12.) -- (7.,13.) -- (8.,12.) -- (9.,12.) -- (9.,14.) -- (10.,15.) -- (9.,16.) -- (7.934442391472151,15.863351386094383) -- (6.934442391472151,14.863351386094383) -- (5.,16.) -- (5.,14.) -- (6.,13.) -- cycle;
\fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (12.,8.) -- (12.,7.) -- (13.,8.) -- cycle;
\fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (12.,5.) -- (12.,4.) -- (11.,4.) -- cycle;
\fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (16.,5.) -- (16.,4.) -- (17.,4.) -- cycle;
\fill[line width=2.pt,color=zzttqq,fill=zzttqq,fill opacity=0.10000000149011612] (16.,7.) -- (16.,8.) -- (15.,8.) -- cycle;
\draw [line width=2.4pt] (4.,8.)-- (5.,7.);
\draw [line width=2.4pt] (5.,7.)-- (4.,6.);
\draw [line width=2.4pt] (4.,6.)-- (5.,5.);
\draw [line width=2.4pt] (5.,5.)-- (4.,4.);
\draw [line width=2.4pt] (4.,4.)-- (6.,4.);
\draw [line width=2.4pt] (6.,4.)-- (7.,3.);
\draw [line width=2.4pt] (7.,3.)-- (8.,4.);
\draw [line width=2.4pt] (8.,4.)-- (8.,8.);
\draw [line width=2.4pt] (8.,8.)-- (7.,9.);
\draw [line width=2.4pt] (7.,9.)-- (6.,8.);
\draw [line width=2.4pt] (6.,8.)-- (4.,8.);
\draw [line width=2.4pt] (12.,7.)-- (13.,8.);
\draw [line width=2.4pt] (13.,8.)-- (15.,8.);
\draw [line width=2.4pt] (15.,8.)-- (16.,7.);
\draw [line width=2.4pt] (16.,7.)-- (16.,5.);
\draw [line width=2.4pt] (16.,5.)-- (17.,4.);
\draw [line width=2.4pt] (17.,4.)-- (11.,4.);
\draw [line width=2.4pt] (11.,4.)-- (12.,5.);
\draw [line width=2.4pt] (12.,5.)-- (12.,7.);
\draw [line width=2.4pt] (5.,12.)-- (7.,13.);
\draw [line width=2.4pt] (7.,13.)-- (8.,12.);
\draw [line width=2.4pt] (8.,12.)-- (9.,12.);
\draw [line width=2.4pt] (9.,12.)-- (9.,14.);
\draw [line width=2.4pt] (9.,14.)-- (10.,15.);
\draw [line width=2.4pt] (10.,15.)-- (9.,16.);
\draw [line width=2.4pt] (9.,16.)-- (7.934442391472151,15.863351386094383);
\draw [line width=2.4pt] (7.934442391472151,15.863351386094383)-- (6.934442391472151,14.863351386094383);
\draw [line width=2.4pt] (6.934442391472151,14.863351386094383)-- (5.,16.);
\draw [line width=2.4pt] (5.,16.)-- (5.,14.);
\draw [line width=2.4pt] (5.,14.)-- (6.,13.);
\draw [line width=2.4pt] (6.,13.)-- (5.,12.);
\draw [line width=2.4pt,color=ffqqqq] (6.934442391472151,14.863351386094385)-- (9.,16.);
\draw [line width=2.4pt,color=ffqqqq] (5.,14.)-- (5.,12.);
\draw [line width=2.4pt,color=ffqqqq] (5.,12.)-- (8.,12.);
\draw [line width=2.4pt,color=ffqqqq] (9.,14.)-- (9.,16.);
\draw (6.912772183756885,16.412831099000936) node[anchor=north west] {$\mathbf{T}_1$};
\draw (9.19952818223592,15.068356466729343) node[anchor=north west] {$\mathbf{T}_2$};
\draw (6.614000043252086,12.390898438359413) node[anchor=north west] {$\mathbf{T}_1$};
\draw (5.131630576901355,13.045898900235319) node[anchor=north west] {$\mathbf{T}_2$};
\draw [line width=2.pt,color=ffqqqq] (6.,8.)-- (8.,8.);
\draw [line width=2.pt,color=ffqqqq] (6.,4.)-- (8.,4.);
\draw [line width=2.pt,color=ffqqqq] (4.,4.)-- (4.,8.);
\draw (6.614000043252086,12.390898438359413) node[anchor=north west] {$\mathbf{T}_1$};
\draw (6.614000043252086,12.390898438359413) node[anchor=north west] {$\mathbf{T}_1$};
\draw (6.614000043252086,12.390898438359413) node[anchor=north west] {$\mathbf{T}_1$};
\draw (4.108910557481083,5.025016051298794) node[anchor=north west] {$\mathbf{T}_1$};
\draw (4.143384266000868,7.116421034832386) node[anchor=north west] {$\mathbf{T}_1$};
\draw (6.809351058197531,8.403439486237673) node[anchor=north west] {$\mathbf{T}_1$};
\draw (6.809351058197531,3.6230852381608907) node[anchor=north west] {$\mathbf{T}_1$};
\draw [line width=2.pt,color=ffqqqq] (12.,7.)-- (12.,8.);
\draw [line width=2.pt,color=ffqqqq] (12.,8.)-- (13.,8.);
\draw [line width=2.pt,color=ffqqqq] (12.,5.)-- (12.,4.);
\draw [line width=2.pt,color=ffqqqq] (16.,5.)-- (16.,4.);
\draw [line width=2.pt,color=ffqqqq] (15.,8.)-- (16.,8.);
\draw [line width=2.pt,color=ffqqqq] (16.,8.)-- (16.,7.);
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .