TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Two things:

1) How do I make the semicircle portion of my shape have the same thickness as the straight lines?

2) How do I fill the overall shape with a filling gray colour?

Here is my code so far:

\draw (10,0.4) arc (90:270:0.4cm);
\draw (10,0.4) -- (12,0.4);
\draw (10,-0.4) -- (12,-0.4);
\draw (12,0.4) arc (90:-90:0.4cm);
share|improve this question
The thickness looks the same. So it might depend on the viewer. – kiss my armpit Aug 25 '14 at 19:56
up vote 3 down vote accepted

It is a combination of broken path joins and viewer rendering quality. You can draw it at one shot or put a node instead.

\draw[blue,fill=blue!30] (0,0.4) arc (90:270:0.4cm)-- (2,-0.4) arc (-90:90:0.4cm)--cycle;
\node[draw=red,fill=red!30,rounded corners=0.4cm,minimum height=0.8cm,minimum width=2.8cm,inner sep=0mm,transform shape] at (1,1) {};

enter image description here

share|improve this answer
Thanks, thats exactly what I wanted, +1 – Jack Aug 25 '14 at 20:22

A solution with PSTricks just for fun.


enter image description here

share|improve this answer
+1 for the effort, thanks. – Jack Aug 25 '14 at 20:23

Just for comparison, in Metapost you can either draw the path directly using halfcircles or use the rboxes library to make rounded boxes.

enter image description here


% A macro that returns the path of a rectangle with rounded ends
vardef vessel(expr width, height) = 
   halfcircle rotated -90 scaled height shifted (+1/2 width,0) --
   halfcircle rotated +90 scaled height shifted (-1/2 width,0) --

% for the alternative approach
input rboxes;


   % draw the shape centred at the origin
   draw vessel(40,20);

   % in order to fill, draw and label the shapes, you can save them as path variables
   path a,b; 

   a = vessel(55,21) shifted 30 up;
   fill a withcolor .4 blue + .6 white;
   draw a withcolor .8 blue;
   label(btex Vessel $V_1$ etex, center a);

   b = vessel(55,21) shifted 55 up;
   fill b withcolor .4 red + .6 white;
   draw b withcolor .8 red;
   label(btex Vessel $V_2$ etex, center b);

   % or you might prefer the "rboxes" approach
   rboxit.c(btex Vessel $V_3$ etex);
   c.dx = 18; c.dy = 5;
   c.s = 70 up; 
   fill bpath.c withcolor .85 white;

share|improve this answer

Your Answer


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.