# How do I get this scope on top of my other lines?

Yo

\begin{tikzpicture}
\draw (0,0) -- (0,3cm);
\draw (0.5cm,0) -- (0.5cm,3cm);
\draw (3cm,0) -- (3cm,3cm);
\draw (3.5cm,0) -- (3.5cm,3cm);
\draw (0,0) arc (0:180:-1.75cm);
\draw (0.5cm,0) arc (0:180:-1.25cm);

\draw [fill=blue,blue] (0,0) rectangle (0.5cm,1cm);
\draw [fill=blue,blue] (3cm,0) rectangle (3.5cm,2.5cm);
\draw[dashed] (0.5cm,1cm) -- (4.5cm,1cm);
\draw[dashed] (3.5cm,2.5cm) -- (4.5cm,2.5cm);
\draw[<->] (4.5cm,1cm) -- (4.5cm,2.5cm) node[midway,right] {$\Delta h$};

\def\Radius{1.75cm}
\def\radius{1.25cm}
\begin{scope}[even odd rule]
\clip circle[radius=\Radius];
\clip[rotate=0] (0,0) -- (0:\Radius) arc (0:-180:\Radius)--cycle;
\fill[blue]
circle[radius=\Radius]
circle[radius=\radius]
;
\end{scope}
\end{tikzpicture}


For some reason, the scope isn't on top of my other lines although I have set them all up to start at (0,0). Any suggestions on how I make this work? • Welcome to TeX.SX! Please always provide a full MWE that also comprises your documentclass etc. – Jasper Habicht Aug 6 '18 at 17:19

## 3 Answers

This is not an answer but just a comment. You can do that much easier. (EDIT: fixed the water level on the left, sorry, did not pay enough attention.)

\documentclass[border=3.14mm,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw [double distance=0.5cm] (0.25,3) -- (0.25,0) arc(0:180:-1.5cm)
-- (3.25,3);
\draw [blue,line width=0.5cm] (0.25,1) -- (0.25,0) arc(0:180:-1.5cm)
-- (3.25,2.5);
\draw[dashed] (0.5cm,1cm) -- (4.5cm,1cm);
\draw[dashed] (3.5cm,2.5cm) -- (4.5cm,2.5cm);
\draw[<->] (4.5cm,1cm) -- (4.5cm,2.5cm) node[midway,right] {$\Delta h$};
\end{tikzpicture}
\end{document} • Neat and simple solution. – Diaa Aug 6 '18 at 21:09
• @Diaa Thanks for pinging me, this made me spot a(nother) bug, and thanks for your nice comment! ;-) – marmot Aug 6 '18 at 21:24

This is because you draw the first shape using arc and the second by drawing a circle. A circle is drawn around its center which you defined implicitly as (0,0), and hence the shift. You can shift the scope by 1.75cm to fit it to the other shapes.

\documentclass[border=5pt,tikz]{standalone}
\begin{document}

\begin{tikzpicture}

\fill[blue] (0,0) rectangle (0.5cm,1cm);
\fill[blue] (3cm,0) rectangle (3.5cm,2.5cm);

\def\Radius{1.75cm}
\def\radius{1.25cm}
\begin{scope}[xshift=1.75cm,even odd rule]
\clip (0,0) -- (0:\Radius) arc (0:-180:\Radius) -- cycle;
\fill[blue] circle[radius=\Radius] circle[radius=\radius];
\end{scope}

\draw (0,0) -- (0,3cm);
\draw (0.5cm,0) -- (0.5cm,3cm);
\draw (3cm,0) -- (3cm,3cm);
\draw (3.5cm,0) -- (3.5cm,3cm);
\draw (0,0) arc (0:180:-1.75cm);
\draw (0.5cm,0) arc (0:180:-1.25cm);

\draw[dashed] (0.5cm,1cm) -- (4.5cm,1cm);
\draw[dashed] (3.5cm,2.5cm) -- (4.5cm,2.5cm);
\draw[<->] (4.5cm,1cm) -- (4.5cm,2.5cm) node[midway,right] {$\Delta h$};

\end{tikzpicture}

\end{document}


Edit: I rearranged the shapes so that the blue shape is behind the lines. This way, the lines will be visible.

Here is the output: • I am sorry for asking this simple question, but could you refer me the section in the TikZ manual where I can understand what the scope environment does here in your code? – Diaa Aug 6 '18 at 17:32
• I just used this approach because the the OP also used it. The scope is mainly used to make clipping possible (2.11 „Clipping a Path“ on page 35 of the current manual). If you only want to clip a certain part of your drawing you have to use such a scope. Everything in this scope will then be clipped, but the rest of the picture will not be affected by the clipping (see: tex.stackexchange.com/questions/330882/…). – Jasper Habicht Aug 6 '18 at 17:49
• I highly appreciate your consideration to respond to my inquiry. I will certainly look at what you referred to. Thanks! – Diaa Aug 6 '18 at 18:04

slightly modified code of the interesting marmot's "comment" (+1). it exploit more possibilities of double path option . for exercise :-)

\documentclass[tikz, margin=3mm]{standalone}

\begin{document}
\begin{tikzpicture}[DS/.style={double distance=5mm, semithick, double=#1}]
\draw [DS=white]    (0,3) -- (0,0)
(3,2.5) -- (3,3);
\draw [DS=blue!50]  (0,0) arc(0:180:-1.5cm) -- (3,2.5);
%
\draw[densely dashed]   (0.25,0.0) -- (4.45,0.0)
(3.25,2.5) -- (4.45,2.5);
\draw[<->] (4.35,0) -- node[right] {$\Delta h$} (4.35,2.5) ;
\end{tikzpicture}
\end{document}
{"ft_lang_label":"__label__en","ft_lang_prob":0.67453235,"math_prob":0.9549562,"size":937,"snap":"2019-13-2019-22","text_gpt3_token_len":413,"char_repetition_ratio":0.18220793,"word_repetition_ratio":0.0,"special_character_ratio":0.4578442,"punctuation_ratio":0.2868526,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98581433,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,2,null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-05-19T12:40:56Z\",\"WARC-Record-ID\":\"<urn:uuid:f6744c44-5c75-40be-8c62-fd6483bc75d7>\",\"Content-Length\":\"146083\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0f4a2d43-a256-4589-98d3-4803ca687547>\",\"WARC-Concurrent-To\":\"<urn:uuid:987ddb4e-c222-4707-ac8a-cea597265c2a>\",\"WARC-IP-Address\":\"151.101.193.69\",\"WARC-Target-URI\":\"https://tex.stackexchange.com/questions/444876/how-do-i-get-this-scope-on-top-of-my-other-lines/444911\",\"WARC-Payload-Digest\":\"sha1:LTMB5CF4AJSE7YTRCG6MGE77IW3GHCJG\",\"WARC-Block-Digest\":\"sha1:UCIJNCZRSU7CCZNR4KMR6IUDEAQKOVGP\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-22/CC-MAIN-2019-22_segments_1558232254882.18_warc_CC-MAIN-20190519121502-20190519143502-00457.warc.gz\"}"}