4

I realize that there are a bazillion questions on tex.stackexchange about right angle symbols, but all of them (that I can find) seem needlessly complicated, and it's taking me a long time to make sense of the answers.

My question should have a very simple answer. Suppose I have two line segments meeting at a right angle in tikz. Accordingly, I would like to add a right angle symbol to the diagram.

This can be done "by hand" using a very painstaking process. But surely there's an automated way to do it.

Thanks!

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[-] (-12,0) -- (-4.76452,3.41289);
\draw[-] (-5.33333333,4.6188) -- (-4.76452,3.41289);
\end{tikzpicture}
\end{document}

enter image description here

Ben W
  • 203

1 Answers1

6

Is this simple enough?

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[pics/right angle/.style={code={
\draw ({-abs(#1)},0) |- (0,#1);}},pics/right angle/.default=1]
\draw[-] (-12,0) --  pic[sloped,pos=1]{right angle} (-4.76452,3.41289);
\draw[-] (-5.33333333,4.6188) -- (-4.76452,3.41289);
\begin{scope}[yshift=-5cm]
\draw[-] (-12,0) --  pic[sloped,pos=1]{right angle} (-4.76452,3.41289)
--([turn]90:1.3);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

The second example shows how you can use turn to obtain your original output in a simpler fashion.