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.

I'm wondering if someone knows how to place one tikz picture cone face to the other in the horizontal position.

\documentclass[varwidth,margin=0.5cm]{standalone}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{shadings}

\begin{document}
\begin{tikzpicture}
  \fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (3cm and 0.5cm);
  \fill[left color=gray!50!black,right color=gray!50!black,middle  color=gray!50,shading=axis,opacity=0.25] (3,0) -- (0,6) -- (-3,0) arc (180:360:3cm and 0.5cm);
  \draw (-3,0) arc (180:360:3cm and 0.5cm) -- (0,6) -- cycle;
  \draw[densely dashed] (-3,0) arc (180:0:3cm and 0.5cm);
\end{tikzpicture}
\end{document}

Output

share|improve this question

migrated from stackoverflow.com Dec 23 '13 at 20:41

This question came from our site for professional and enthusiast programmers.

    
Your example doesn't compile for me, but does tex.stackexchange.com/questions/119914/… help?¨ –  Torbjørn T. Dec 23 '13 at 22:07
add comment

2 Answers 2

TiKZ 3.0.0 (already available at sourceforge) introduces a new concept call pic

A “pic” is a “short picture” (hence the short name...) that can be inserted anywhere in TikZ picture where you could also insert a node. Similarly to nodes, pics have a “shape” (called type to avoid confusion) that someone has defined. Each time a pic of a specified type is used, the type’s code is executed, resulting in some drawings to be added to the current picture. The syntax for adding nodes and adding pics to a picture are also very similar. The core difference is that pics are typically more complex than nodes and may consist of a whole bunch of nodes themselves together with complex paths joining them.

with 'pics' it's easy to shift, rotate, mirror, ... every piece of your drawings. Next you have two examples:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}

\tikzset{
    cone/.pic={
        \fill[top color=gray!50!black, bottom color=gray!10, 
              middle color=gray,shading=axis,opacity=0.25]           
              (0,0) circle (3cm and 0.5cm);
        \fill[left color=gray!50!black, right color=gray!50!black,
              middle  color=gray!50,shading=axis,opacity=0.25] 
              (3,0) -- (0,6) -- (-3,0) arc (180:360:3cm and 0.5cm);
        \draw (-3,0) arc (180:360:3cm and 0.5cm) -- (0,6) -- cycle;
        \draw[densely dashed] (-3,0) arc (180:0:3cm and 0.5cm);
    },
    cone_inverted/.pic={
        \fill[top color=gray!50!black, bottom color=gray!10,
              middle color=gray, shading=axis, opacity=0.25]           
              (0,-6) circle (3cm and 0.5cm);
        \fill[left color=gray!50!black, right color=gray!50!black,
              middle  color=gray!50, shading=axis, opacity=0.25] 
              (3,-6) -- (0,0) -- (-3,-6) arc (180:360:3cm and 0.5cm);
        \draw (-3,-6) arc (180:360:3cm and 0.5cm) -- (0,0) -- cycle;
        \draw[densely dashed] (-3,-6) arc (180:0:3cm and 0.5cm);
    }
}
\begin{document}
\begin{tikzpicture}
    \path (0,0) pic {cone} pic [rotate=180] {cone};
\end{tikzpicture}
\begin{tikzpicture}
    \foreach \i in {0,60,...,360}
    \path (0,0) pic [rotate=\i] {cone_inverted};
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
add comment

With solution provided by Harish Kumar in Can we mirror a part in tikz? as Torbjørn suggested, it is easy to get this

enter image description here

If this is what you want, the code is:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
\fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25]           (0,0) circle (3cm and 0.5cm);
\fill[left color=gray!50!black,right color=gray!50!black,middle  color=gray!50,shading=axis,opacity=0.25] (3,0) -- (0,6) -- (-3,0) arc (180:360:3cm and 0.5cm);
\draw (-3,0) arc (180:360:3cm and 0.5cm) -- (0,6) -- cycle;
\draw[densely dashed] (-3,0) arc (180:0:3cm and 0.5cm);

\begin{scope}[xscale=1,yscale=-1]
\fill[top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25]           (0,0) circle (3cm and 0.5cm);
\fill[left color=gray!50!black,right color=gray!50!black,middle  color=gray!50,shading=axis,opacity=0.25] (3,0) -- (0,6) -- (-3,0) arc (180:360:3cm and 0.5cm);
\draw (-3,0) arc (180:360:3cm and 0.5cm) -- (0,6) -- cycle;
\draw[densely dashed] (-3,0) arc (180:0:3cm and 0.5cm);
\end{scope}
\end{tikzpicture}

\end{document}
share|improve this answer
add comment

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.