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.

The "oval" path in too sharp as you can see in the intersection with the horizontal line. How can i fix this problem?

\documentclass{article}
\usepackage{tikz}  

\begin{document}

\begin{tikzpicture}[scale=0.3]
  \draw (0,7.5)--(5,7.5);
  \draw[smooth] (0,0) to[out=75,in=285] (0,7.5) to[out=255,in=105] (0,0)-- cycle;
\end{tikzpicture}

\end{document}

enter image description here

I'm tryng to make something like this:

\documentclass{article}
\usepackage{tikz} 
\usetikzlibrary{patterns}  

\begin{document}

\begin{tikzpicture}[scale=0.3]

 \draw[smooth,pattern=north east lines] (0,0) to[out=75,in=285] (0,7.5)   to[out=255,in=105] (0,0)-- cycle;
 \draw (0,-7.5) to[out=105,in=255] (0,0);

\draw (0,7.5)--(20,7.5);
\draw (0,-7.5)--(20,-7.5);

\end{tikzpicture}
\end{document}

enter image description here

share|improve this question

3 Answers 3

Using arcs:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}[scale=0.3]

\draw (20,8)--(0,8); 
\draw[pattern=north east lines] (0,8) arc[start angle=-270,end angle = -90, x radius=1.5cm, y radius=4cm]coordinate[pos=1](a) arc[start angle=-90,end angle = 90, x radius=1.5cm, y radius=4cm];
%
\draw (a) arc[start angle=-270,end angle = -90, x radius=1.5cm, y radius=4cm] --(20,-8);

\end{tikzpicture}
\end{document}

enter image description here

With bends:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}[scale=0.3,line join = round]

\draw (20,8)--(0,8); 
\draw[pattern=north east lines] (0,8) to[bend left] (0,0)coordinate[pos=1](a) to[bend left] (0,8);
%
\draw (a) to[bend right] (0,-8) -- (20,-8);

\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

I'm not sure about what is the intended result.

  1. If you want the curve to be "smooth" at the top and bottom, then drawing it with a pair of "unrelated" arcs won't work. For this, you need either use a ellipse (as other answer suggests), or define appropriate control points, or using your approach, be sure that the in and out angles at the tips guarantees that the tangent of the curve is horizontal at those points. I.e: they should be 0 or 180:

    \begin{tikzpicture}[scale=0.3]
      \draw (0,7.5)--(5,7.5);
      \draw (0,0) to [out=180,in=180] (0,7.5) to[out=0,in=0] (0,0) -- cycle;
    \end{tikzpicture}
    

    Result

    If you want a different aspect ratio for the ellipse, you can play with the parameter looseness, which by default is 1. For example:

    \begin{tikzpicture}[scale=0.3]
      \draw (0,7.5)--(5,7.5);
      \draw (0,0) to [out=180,in=180,looseness=0.5] (0,7.5) to[out=0,in=0, looseness=0.5] (0,0) -- cycle;
    \end{tikzpicture}
    

    produces:

    Result

  2. If you want the curve to have "acute" tips, but you don't want those tips to extend beyond your horizontal line, then the problem is the kind of line join used. By default, tikz uses "miter join" and when two lines join into a corner with a small angle, the width of the lines cause the intersection of them occuring "past the corner". You can use line join=round to fix this problem.

    \begin{tikzpicture}[scale=0.3]
      \draw (0,7.5)--(5,7.5);
      \draw[smooth, line join=round] (0,0) to[out=75,in=285] (0,7.5) to[out=255,in=105] (0,0)-- cycle;
    \end{tikzpicture}
    

    Result

share|improve this answer

You can use the builtin ellipse command in TikZ. Here you go:

\documentclass{article}
\usepackage{tikz}  

\begin{document}

\begin{tikzpicture}[scale=0.3]
  \draw (0,7.5)--(5,7.5);
  \draw (0,3.75) ellipse (0.75 and 3.75);
\end{tikzpicture}

\end{document}

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.