Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Hatching - I suppose in the northeast direction - is to be added to the square with an edge length of $c$ in following diagram. I have a right-angle mark at one of the corners of the square. Is there code to instruct TikZ to draw these hatching lines not to go into the little square made by this right-angle mark? I would like these hatching lines to go to the right-angle mark, though. (What code would instruct TikZ to shade the square with an edge length of $c$? The shading should be drawn in the little square made by this right-angle mark.)

By the way, this is a diagram for a demonstration of the Pythagorean Theorem. I saw one web site that attributed this diagram to the 12 century Indian mathematician Bhaskara. Does anybody have a citation for this?

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}


\begin{document}

\begin{tikzpicture}
\path (-3,-3) coordinate (A) (-3,3) coordinate (B) (3,3) coordinate (C) (3, -3) coordinate (D);
\path (-3,-1) coordinate (P) (-1,3) coordinate (Q) (3,1) coordinate (R) (1,-3) coordinate (S);
\draw (A) -- (P) node [midway, left]{$a$} -- (B) node [midway, left]{$b$}
-- (Q) node [midway, above]{$a$} -- (C) node [midway, above]{$b$}
-- (R) node [midway, right]{$a$} -- (D) node [midway, right]{$b$} 
-- (S) node [midway, below]{$a$} -- (A) node [midway, below]{$b$};
\draw (P) -- (Q) node [midway, left]{$c$} -- (R) node [midway, right, above]{$c$} -- (S) node [midway, right]{$c$} -- (P) node [midway, below]{$c$};
\draw[|<->|] ($(A)!7mm!-90:(D)$)--node[fill=white,sloped] {$a + b$} ($(D)!7mm!90:(A)$);
\draw[|<->|] ($(A)!7mm!90:(B)$)--node[fill=white,sloped] {$a + b$} ($(B)!7mm!-90:(A)$);
\tkzMarkRightAngle(P,A,S);
\tkzMarkRightAngle(Q,P,S);
\end{tikzpicture}

\end{document}
share|improve this question

1 Answer 1

up vote 7 down vote accepted

To hatch the square you can use the patterns by loading the patterns library;

\draw[pattern=north east lines] (P) -- (Q) node [midway, left]{$c$}
     -- (R) node [midway, right, above]{$c$} -- (S) node [midway, right]{$c$}   
     -- (P) node [midway, below]{$c$} -- cycle;

Also, angle marking accepts drawing options

\tkzMarkRightAngle[fill=white](Q,P,S);

fills the square. Then you get

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.