1

I know this question has already been asked a couple times in a similar way to mine. However, I can't figure out, what I am doing wrong. I want to color this quadrilateral.

\begin{tikzpicture}
    \draw (3,-.5) to [<-, bend right=10] (1.5,0) node[left]{};
    \draw (2,-1) to [<-, bend left=10] (.5,-.8) node[left]{};
    \draw[dashed] (2,-1) -- (3,-.5) node[left] {};
    \draw (.5,-.8) to (1.5,0) node[left]{};
\end{tikzpicture}

You might have to include some of the following in order to compile it.

\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{verbatim}
\usetikzlibrary{intersections}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{backgrounds}

I found a site which used this code to color a triangle.

\def\KurveI{(3,-.5) to (1.5,0)}
  \def\KurveII{(.5,-.8) to (1.5,0)}
  \def\KurveIII
      {(.5,-.8) to (3,-.5)}
  \draw \KurveI \KurveII \KurveIII 
    (current path bounding box.south west)coordinate(UL)
    (current path bounding box.north east)coordinate(OR);
  \begin{scope}[on background layer]
    \clip (UL)--\KurveI--(UL-|OR)--cycle;% Fläche unterhalb der 1.Kurve
    \clip (UL-|OR)--\KurveII--(OR)--cycle;% Fläche rechts von 2.Kurve
    \clip (UL|-OR)--\KurveIII--(OR)--cycle;% Fläche oberhalb von 3.Kurve
    \fill[yellow!50](UL)rectangle(OR);% Füllen der Schnittfläche
  \end{scope}

However, when I copy it, it only colors part of my triangle. Is there a site, where it is explained how to color surfaces with tikz? Or what am I doing wrong?

Here is some Code that should compile.

\documentclass[12pt]{article}
\usepackage[ngerman]{babel}
\usepackage{tikz}       

\usetikzlibrary{intersections}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{backgrounds}                        

\begin{document}

\begin{tikzpicture}
\draw (3,-.5) to [<-, bend right=10] (1.5,0);
\draw (2,-1) to [<-, bend left=10] (.5,-.8);
\draw[dashed] (2,-1) -- (3,-.5) ;
\draw (.5,-.8) to (1.5,0);
\end{tikzpicture}

\begin{tikzpicture}
\def\KurveI{(3,-.5) to (1.5,0)}
  \def\KurveII{(.5,-.8) to (1.5,0)}
  \def\KurveIII
      {(.5,-.8) to (3,-.5)}
  \draw \KurveI \KurveII \KurveIII 
    (current path bounding box.south west)coordinate(UL)
    (current path bounding box.north east)coordinate(OR);
  \begin{scope}[on background layer]
    \clip (UL)--\KurveI--(UL-|OR)--cycle;
    \clip (UL-|OR)--\KurveII--(OR)--cycle;
    \clip (UL|-OR)--\KurveIII--(OR)--cycle;
    \fill[yellow!50](UL)rectangle(OR);
  \end{scope}
\end{tikzpicture}

\end{document}
6
  • Welcome to TeX.SX! Could you please make a compilable example that shows the issue?
    – egreg
    Feb 24, 2018 at 16:43
  • I edited it, it should compile now.
    – Teywazz
    Feb 24, 2018 at 16:51
  • please merge your code snippets in one small complete document! help us to help you! package tikz has manual, where are described all aspect of its use in detail.
    – Zarko
    Feb 24, 2018 at 17:03
  • What is the purpose of all the node[left]{} statements?
    – user121799
    Feb 24, 2018 at 17:14
  • The node[left]{} statements are not important here, I will use them later for adding formulas.
    – Teywazz
    Feb 24, 2018 at 17:28

1 Answer 1

0

Just to approach an answer, I show you how you may fill the shape.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[blue] (1.5,0) to[bend left=10]  (3,-.5)  to (2,-1)  to [bend left=10]  (.5,-.8) to cycle;
   \draw (3,-.5) to [<-, bend right=10] (1.5,0) node[left]{};
    \draw (2,-1) to [<-, bend left=10] (.5,-.8) node[left]{};
    \draw[dashed] (2,-1) -- (3,-.5) node[left] {};
    \draw (.5,-.8) to (1.5,0) node[left]{};
\end{tikzpicture}
\end{document}
1
  • Thank you, this fill command is exactly what I was looking for.
    – Teywazz
    Feb 24, 2018 at 17:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .