Graphics, Figures & TablestikZ | A simple Diagram

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
thinkpadT
Posts: 25
Joined: Wed Sep 26, 2012 5:46 pm

tikZ | A simple Diagram

Post by thinkpadT »

Hi everyone,

I just started using tikZ together and find it to be very suitable for my needs. I wanted to draw the attached diagram, had a difficult time. I would appreciate any starting help.


Thanks a lot in advance :D
Fawad
Attachments
laser-principal.png
laser-principal.png (48.63 KiB) Viewed 4610 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tikZ | A simple Diagram

Post by localghost »

thinkpadT wrote:[…] I wanted to draw the attached diagram, had a difficult time. […]
Then you can for sure show your recent efforts in form of a concrete code example. It's easier and faster to correct some presented code than to write something from scratch.


Best regards and welcome to the board
Thorsten
thinkpadT
Posts: 25
Joined: Wed Sep 26, 2012 5:46 pm

tikZ | A simple Diagram

Post by thinkpadT »

hi Thorsten,

you are totally right about that. so here is my humble code that worked for me.
I need to place the caption at right place, how can i achieve that :) ?
Another thing that would be nice, if the diagrams were not so small, i want them to be one page large, can i get some help on that, too :)

Code: Select all

\documentclass{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}

\begin{document}
 \begin{tikzpicture}
  \begin{tikzpicture}
   \draw[gray,fill=gray!10] (-1.5,0.5) rectangle +(3,-1);
   \fill[blue,path fading=east] (0:0) -- (10:6) -- (-10:6) -- cycle;
   \fill[blue,path fading=west] (0:0) -- (-10:-6) -- (10:-6) -- cycle;
   \fill[red,path fading=east] (0:0) -- (3:6) -- (-3:6) -- cycle;
  \end{tikzpicture}
\end{document}
Thanks very much
Fawad
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

tikZ | A simple Diagram

Post by mas »

Hi,

See whether the following code is suitable for you:

Code: Select all

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  %\draw[help lines,step=.5,lightgray] (-5,-2) grid (5,2) ;

  \path [draw=black,fill=red!70] (-5,1) -- (0,0) -- (-5,-1) -- cycle ;
  \path [draw=black,fill=red!70] (5,1) -- (0,0) -- (5,-1) -- cycle ;
  \path [draw=black,fill=blue!70] (5,0.3) -- (0,0) -- (5,-0.3) -- cycle ;

  \draw [gray] (-1,-.4) rectangle (1,.4) ;
  \node [below] at (0,-0.5) {gas cell} ;

  \draw (-3,0) -- (-3,1.5) node[above] {\small pump laser} ;
  \draw (3,0) -- (3,1.5) node[above] {\small higher harmonics} ;
  
\end{tikzpicture}

\end{document}
Regards.
Attachments
laser.png
laser.png (22.36 KiB) Viewed 4587 times
Last edited by mas on Thu Sep 27, 2012 1:58 pm, edited 1 time in total.

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
thinkpadT
Posts: 25
Joined: Wed Sep 26, 2012 5:46 pm

Re: tikZ | A simple Diagram

Post by thinkpadT »

Thanks alot for your help guys, i got a neat and clean diagram of what i wanted.

Thx
Fawad
Attachments
hhg.jpg
hhg.jpg (14.83 KiB) Viewed 4587 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: tikZ | A simple Diagram

Post by localghost »

And it would be very kind if you post the complete solution so that others with the a similar problem who come here by search engine can benefit.
thinkpadT
Posts: 25
Joined: Wed Sep 26, 2012 5:46 pm

tikZ | A simple Diagram

Post by thinkpadT »

hi localghost,
For sure, here is the code to the final result i have got

Code: Select all

\documentclass[landscape]{article}

\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}

 \begin{tikzpicture}[domain=1:1]
	
%------------------fundamental and harmonics
  \fill[blue,path fading=east] (0:0) -- (10:6) -- (-10:6) -- cycle;
  \fill[blue,path fading=west] (0:0) -- (-10:-6) -- (10:-6) -- cycle;
  \fill[red,path fading=east] (0:0) -- (3:6) -- (-3:6) -- cycle;
  
%-----------captions
  \draw (-3,0) -- (-3,1.5) node[above] {\small pump laser} ;
  \draw (3,0) -- (3,1.5) node[above] {\small higher harmonics} ;
  \node [below] at (0,-0.5) {gas cell} ;

%----------transparent gas cell
  \begin{scope}[fill opacity = 0.3]
  \draw[gray!25,fill=gray!10] (-1.5,0.5) rectangle +(3,-1);
  \end{scope}

 \end{tikzpicture}

\end{document}
Thanks again everyone
-Fawad
Post Reply