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

I'm trying to draw some arbitrary closed two dimensional curve where I'm focusing on only part of the boundary. I want to label the diameter of the part of the boundary I'm focusing on. Last, I'd like to put a tube encompassing this part of the boundary, and label both. Here is a picture of the situation I desire: enter image description here

The symbols are $\Omega$, $\operatorname{diam} (\partial \varphi)$, $\operatorname{diam} (\mathcal{R}_i)$, and $\partial \phi^2$.

Any help would be greatly appreciated. I understand how to get one simple closed curve, but not two overlapping as in the picture above with two straight lines stretching as shown labeled above.

share|improve this question
The hobby library may be useful in creating a nice-looking "arbitrary closed curve." – Charles Staats Nov 8 '13 at 22:25
@Charles Staats The hobby library? – Anthony Peter Nov 8 '13 at 22:29
please refer to this link : tex.ac.uk/ctan/graphics/pgf/contrib/hobby/hobby_doc.pdf. Hobby is a tikz library. – s__C Nov 8 '13 at 22:33
@s__C Could you help in constructing the desired diagram? – Anthony Peter Nov 8 '13 at 22:59
The tube edges are straight lines or curvy lines? – kiss my armpit Nov 8 '13 at 23:09
up vote 12 down vote accepted

Thanks to Marienplatz for providing the coordinates

Using tikz and hobby. Code could have been minimized and refined, but let us be elaborative ;-)



\begin{tikzpicture}[line width=1pt,line cap = round]
\node[fill=black,circle,inner sep=0pt,outer sep=0pt,label={[xshift=1pt]below right:$\partial \phi^2$}] at (0,1) (a) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (1,3) (b) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (4,4) (c) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (5,2) (d) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (4.5,.5) (e) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (4,0) (f) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (3,.2) (g) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (1,0) (h) {};

\path[draw,use Hobby shortcut,closed=true]
(a) .. (b) .. (c) .. (d) .. (e) .. (f) .. (g) .. (h);

\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (4.5,4.5) (i) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt] at (5,4.8) (j) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt,label={[xshift=4pt]below left:$\Omega$}] at (7.7,5.6) (k) {} ;
\node[fill=black,circle,inner sep=0pt,outer sep=0pt,xshift=1cm,yshift=-2cm] at (4.5,4.5) (l) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt,xshift=1cm,yshift=-2cm] at (5,4.8) (m) {};
\node[fill=black,circle,inner sep=0pt,outer sep=0pt,xshift=1cm,yshift=-2cm] at (7.7,5.6) (n) {};

\draw (c) to [quick curve through={(i) . . (j)}] (k)
      (k) -- node[midway,below,sloped]{$\alpha$} (n)
      (n) to [quick curve through={(m) . . (l)}] (d)
      (m) -- node[midway,below,sloped]{$\operatorname{diam} (\mathcal{R}_i)$} (j)
      (d) -- node[midway,below,sloped]{$\operatorname{diam} (\partial \varphi)$} (c);



enter image description here

With lesser lines and edits for the comment:


\begin{tikzpicture}[line width=.6pt,line cap = round,scale=.5,transform shape]

\foreach \x/\y/\z in {0/1/a,1/3/b,4/4/c,5/2/d,4.5/.5/e,4/0/f,3/.2/g,1/0/h}{
\coordinate (\z) at (\x,\y);
\foreach \x/\y/\z in {4.5/4.5/i,5/4.8/j,7.7/5.6/k}{
\coordinate (\z) at (\x,\y);
\foreach \x/\y/\z in {4.5/4.5/l,5/4.8/m,7.7/5.6/n}{
\coordinate[xshift=1cm,yshift=-2cm] (\z) at (\x,\y);

\path[draw,use Hobby shortcut,closed=true]
(a) .. (b) .. (c) .. (d) .. (e) .. (f) .. (g) .. (h);

\draw (c) to [quick curve through={(i) . . (j)}] (k)
      (k) -- node[midway,left]{$\alpha$} (n)
      (n) to [quick curve through={(m) . . (l)}] (d)
      (m) -- node[midway,below,sloped]{$\operatorname{diam} (\mathcal{R}_i)$} (j)
      (d) -- node[midway,below,sloped]{$\operatorname{diam} (\partial \varphi)$} (c);

\node[xshift=12pt,yshift=-5pt] at (a.-30) {$\partial \phi^2$};
\node[xshift=-3pt,yshift=-5pt] at (k.220) {$\Omega$};

\caption{Some description for this figure}


enter image description here

I have used scale=.5,transform shapein tikzpicture options to scale it down. Also added \alpha in the rightmost line.

share|improve this answer
Eh! What is the equivalent of \pstTranslation{C}{D}{C1,C2,C3} in tikz? – Harish Kumar Nov 9 '13 at 1:22
How would I scale it down? And add a $\alpha$ halfway down the rightmost line. (the one to the right of omega) – Anthony Peter Nov 9 '13 at 2:44
If you rotate the alpha so its horizontal, I'll accept your answer. – Anthony Peter Nov 9 '13 at 3:06
@AnthonyPeter That is easy. Change (k) -- node[midway,below,sloped]{$\alpha$} (n) to (k) -- node[midway,left]{$\alpha$} (n). See the edit. – Harish Kumar Nov 9 '13 at 3:16
much appreciated. – Anthony Peter Nov 9 '13 at 3:17

Complete Code

The complete input files are given as follows.


% let the name of this file be diagram.tex
% Compile it with 
% latex diagram, followed by
% dvips diagram, followed by
% ps2pdf -dAutoRotatePages=/None diagram.ps (if you are using Windows, please replace = with #)
    \ncline{C}{D}_{$\diam (\partial \varphi)$}
    \ncline{C2}{D2}_{$\diam (\mathcal{R}_i)$}
    \uput{6pt}[-30](A){$\partial \phi^2$}

enter image description here


% let the name of this file be main.tex
% compile it with
% pdflatex main (it needs compilation twice or more to make the cross references get properly linked)
% make sure diagram.pdf exists!
\usepackage{lipsum,xcolor}% for dummy text and color, you might not need it in your production!
\caption{Diagraming with PSTricks is always fun!}
\textcolor{red}{See page~\pageref{fig:diagram}, there is a beautiful example of PSTricks there.}


enter image description here


Sadly my coordinates are copied by another answerer without paying the license fee. :-)

Diagram Management

  • Every diagram should be composed in a single, separate, standalone input file. This approach will make your project becomes easier to maintain. It also allows you to reuse the diagrams for other projects. Use standalone document class to get a tight output so any excessive white spaces (excluding the intentionally added borders) will be trimmed.
  • The recommended approach is to save the input file of each diagram in the same directory (named Diagrams, for example) and should be one at least 2 level higher than the individual project directory. See the directory structure below to illustrate the explanation better.

    /other directory/
    /other directory/my documents/
    /other directory/my documents/Diagrams/
    /other directory/my documents/Diagrams/Diagram1.tex/
    /other directory/my documents/Diagrams/Diagram2.tex/
    /other directory/my documents/Diagrams/Diagramn.tex/
    /other directory/my documents/Projects/
    /other directory/my documents/Projects/Project 1/Main.tex/
    /other directory/my documents/Projects/Project 2/Main.tex/
    /other directory/my documents/Projects/Project n/Main.tex/
  • Compile each diagram containing PSTricks code with

    latex filename
    dvips filename
    ps2pdf -dAutoRotatePages=/None filename.ps

    For users with legacy Windows, replace = with #. Now we have PDF version for each diagram.

Project Management

  • Every project input file (named Main.tex, for example) should be in a separate project folder. It is also useful for easy maintenance.
  • Compile the Main.tex with pdflatex Main.tex to get a PDF output. You need 2 or more compilations to make the cross-references get properly rendered or linked.
  • Import the PDF diagrams from Main.tex using \includegraphics{<digram-name>} provided by graphicx package. Don't forget to set the \graphicspath{{../../Diagrams/},{other-path-if-any/}} right after \usepackage{graphicx}.
share|improve this answer
Very impressive – Anthony Peter Nov 9 '13 at 2:10
How would I scale it down? – Anthony Peter Nov 9 '13 at 2:14
Also how would I add a caption labeling it "Figure N.n : blah blah" – Anthony Peter Nov 9 '13 at 2:42
@AnthonyPeter: Sorry for lately responding. I was sleeping when you asked. See my update. – kiss my armpit Nov 9 '13 at 9:33
License fee paid through an upvote already ;-) – Harish Kumar Nov 9 '13 at 12:25

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.