# How do I create those forms with Tikz?

I want to create a graphic that is similar to those two: http://imgur.com/a/0TCAH

The first one corresponds more to what I'm looking for. I just got 2 questions. How do i create the lines at the grating coupler? My idea would have been to use patterns, but they don't vary the gaps. So is there an easy way to generate parallel lines with varying gaps?

How would you create the microheater from example no.1 and the ring? I would go with a patchwork like attempt, since the ring isn't a real, but rather 2 half circles with a straight line connecting the ends(or a rectangle with rounded corners) and for the microheater I would most likely end up with defining a lot of points and filling the area in between, but it looks really smooth in this picture, so is there a smooth way to do it?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[auto]
\fill[fill=orange](3.7,2) -- (4.3,2) -- (4.7,3)--(3.3,3);
\node[orange, rounded corners=10pt, draw, line width=3mm,minimum width=2.5em,minimum height=2em](FilterMRR)at (4,1.5){};
\fill[fill=white](3.9,1.5) rectangle (4.1,3);
\draw[line width=1mm](0,2) to (5,2);
\draw[line width=1mm](0,1) to (5,1);
\draw[line width=1mm](0,0) to (5,0);
\node[rounded corners=10pt, draw, line width=1mm,minimum width=2.5em,minimum height=2em](FilterMRR)at (4,1.5){};
\node[rounded corners=10pt, draw, line width=1mm,minimum width=2.5em,minimum height=2em](SensorrMRR)at (1,0.5){};
\fill[fill=black](4.8,0.0) -- (5.2,0.1) -- (5.2,-0.1);
\node[minimum width=3mm,minimum height=1mm,pattern=vertical lines](output)at (5.4,0){};
\draw[gray,line width=1mm] (0.5,-0.2) rectangle (1.5,1.2);
\end{tikzpicture}
\end{document}


Greetings, every help or link is appreciated.

• Welcome to TeX - LaTeX! Try looking at other questions here with examples tikz and look at the tutorials in the manual. When you have some code, please show us what you have tried, and what you need help with by editing your question. – Andrew Swann Feb 11 '17 at 12:57
• I will word my question diffrently, since I already have some experience with tikz. – Maver Feb 11 '17 at 13:16
• If you have some experience with tikz could you add some code (as a minimal working example (MWE)) to show what you can already draw of the diagram, this better highlights what you need help with and reduces the amount of work required for somebody to provide a useful and complete answer. It's generally preferred to upload pictures through the site rather than linking to externally hosted images which could disappear without notice. – Dai Bowen Feb 11 '17 at 17:31
• Like I already mentioned, I can recreate the image "patchworkwise". It's just the micro heater. – Maver Feb 11 '17 at 18:22
• Also added a patchwork microheater. It just isn't as smooth as the original. – Maver Feb 11 '17 at 18:54

As far as the microheater, what I understand is that you want the sharp corners from the missing bit on the top to be smoothed.

A somewhat hacky approach, construct a larger white box over the gap in the middle and then redraw the node but this time clip the image with a rectangle with the rounded corners option.

Namely, from the MWE above do

\fill[fill=white](3.8,1.5) rectangle (4.2,2);


then redraw the node with a clipping area which removes the sharpness of the relevant corner (and is large enough that the other corners of the clipping area lie well beyond the edges of the node).

\begin{scope}
\clip [rounded corners] (3,1.66) rectangle (3.9,3);
\node[orange, rounded corners=10pt, draw, line width=3mm,minimum width=2.5em,minimum height=2em] at (4,1.5){};
\end{scope}


The 1.66 as the minimum height of the clipped region came purely by eye and would likely need some adjustment should you set the size of the rounding.

However, while not the most glamorously automated approach, to my eye it works pretty well without too much manual labour.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns}
\begin{document}
\begin{tikzpicture}[auto]
\fill[fill=orange](3.7,2) -- (4.3,2) -- (4.7,3)--(3.3,3);
\node[orange, rounded corners=10pt, draw, line width=3mm,minimum width=2.5em,minimum height=2em](HeaterMRR)at (4,1.5){};
\fill[fill=white](3.9,1.5) rectangle (4.1,3);
\fill[fill=white](3.8,1.5) rectangle (4.2,2);

\begin{scope}
\clip [rounded corners] (3,1.66) rectangle (3.9,3);
\node[orange, rounded corners=10pt, draw, line width=3mm,minimum width=2.5em,minimum height=2em] at (4,1.5){};
\end{scope}

\begin{scope}
\clip [rounded corners] (5,1.66) rectangle (4.1,3);
\node[orange, rounded corners=10pt, draw, line width=3mm,minimum width=2.5em,minimum height=2em] at (4,1.5){};
\end{scope}

\draw[line width=1mm](0,2) to (5,2);
\draw[line width=1mm](0,1) to (5,1);
\draw[line width=1mm](0,0) to (5,0);
\node[rounded corners=10pt, draw, line width=1mm,minimum width=2.5em,minimum height=2em](FilterMRR)at (4,1.5){};
\node[rounded corners=10pt, draw, line width=1mm,minimum width=2.5em,minimum height=2em](SensorrMRR)at (1,0.5){};
\fill[fill=black](4.8,0.0) -- (5.2,0.1) -- (5.2,-0.1);
\node[minimum width=3mm,minimum height=1mm,pattern=vertical lines](output)at (5.4,0){};
\draw[gray,line width=1mm] (0.5,-0.2) rectangle (1.5,1.2);
\end{tikzpicture}
\end{document}


Zooming in a lot closer, you can see a kink but having only used the default length for the rounded corners option and not spent long on adjusting the minimum height of the clipping region, there's still plenty of room to improve if desired.

As far as the lines on the input output, what you've got

\node[minimum width=3mm,minimum height=1mm,pattern=vertical lines](output)at (5.4,0){};
\draw[gray,line width=1mm] (0.5,-0.2) rectangle (1.5,1.2);


looks reasonable enough to me, maybe there are fancier ways to use patterns, but if you want something less regular then these are just vertical lines and the image you give as reference only has three of them so I would suggest that for the use case given so far, they could be manually drawn without expending too much effort.

• Still don't get how scope exactly works, but it works for me and I could smoothen it out. – Maver Feb 12 '17 at 18:32
• @Maver the role of the scope is just to restrict over which drawing commands the \clip runs. Try removing one of the scope environments and you'll see that all the following drawing commands after the clip suddenly draw a lot less, if you change the \clip you'll notice what gets draws changes it. The scope just means that only things drawn within the scope get clipped. – Dai Bowen Feb 12 '17 at 18:39