General ⇒ Graphics in latex
Graphics in latex
I want to draw a fig. as attached in the JPG file in latex, I know a way to draw the figure in any application(like corel draw) and then insert it in my latex file using graphic command, however fonts used to label those figs. get different, are there any tool(s) where in we draw the fig. lable it and the the tool gives us the latex code for it.
I've manually tried coding and drawing some graphics, but the coding is too complex, are there any good tutorials ?
Please let me know most easiest and efficient way that will enable me to insert/draw figs of different types, including the one that is attached.
Hope someone will try to help me out and show me the easiest possible way to deal with the above issue.
metric.
- Attachments
-
- latex_fig.JPG (8.4 KiB) Viewed 8234 times
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
Graphics in latex
For point-and-click drawing I would go for something like IPE. For programmatic drawing I'm sold on pgf/tikz. It's extremely powerful and comes with an excellent documentation. See also http://www.fauskes.net/pgftikzexamples/ for examples.
Cheers,
Tomek
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Graphics in latex
The standard picture environment (perhaps enhanced by the pict2e package) would not be the right way to do such drawings. Take a look at pgf/TikZ or PSTricks. For both there are example libraries available in the web [1,2]. If you want to compile your document with pdflatex directly to PDF, you should prefer the first one.metric wrote:[...] I've manually tried coding and drawing some graphics, but the coding is too complex, are there any good tutorials ? [...]
[1] PGF and TIKZ examples gallery | fauskes.net
[2] /PSTricks/examples
Best regards
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Graphics in latex
Code: Select all
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[>=latex] % option '>=latex' for nice arrows
\def\wlen{2}
\def\vlen{3}
\def\angle{25}
\def\arcrad{0.6}
\draw[->,thick] (0,0) -- (0,\wlen) node[below left] {$w$};
\draw[->,thick] (0,0) -- (\angle:\vlen) node[pos=0.8,below right] {$v$};
\draw (0,\wlen) -- ++(\angle:\vlen) -- ++(0,-\wlen);
\draw[->,thin] (\angle:\arcrad) arc (\angle:90:\arcrad);
\node[above right] at (80:\arcrad) {$\theta$};
\draw[->,densely dashed] (0,\wlen) -- (\angle:\vlen) node[pos=0.6,above right] {$v-w$};
\draw[<-,loosely dashed] (0,\wlen) ++(\angle:\vlen)-- (0,0) node[at start,right] {$v+w$};
\end{tikzpicture}
\end{document}
Tomek
- Attachments
-
- vectors.png (8.96 KiB) Viewed 8212 times
Re: Graphics in latex
Thank you once again for the help.
metric
Re: Graphics in latex
When i compile the code provided by you, I get the following error msg.
\pgfsetsnakessegmenttransformation
{\pgf@snake@mirror\pgf@sanake@raise}
! Undefined control sequence.
1.1837 \pgfdeclareplotmark {ball}
when i keep pressing enter i get diff. error msgs, like
Package kyval Errr: tikz undefined.
!undfined control sequence.
\tikz@set@one@key.... after !\expandafter {\XKV@rm}\ifin@ \expandafter \tikz....
I tried uninstalling and then again installing the pgf package, still the same error comes. I also used synchronized and refresh FNDB option from seetings, but still same error comes.
I use Miktex2.7 on winXP with SP2. and LED as an editor.
can you make out why this is happening, Please if you can assist, would be of great help.
Best Regards,
Arif
Re: Graphics in latex
I don't see Ted in this thread, so perhaps you are trying the example I posted (the only one in this thread so far). If that's the case, I don't have any troubles to compile it with either pdflatex or latex+dvips. Tested with MiKTeX 2.7 on XP and Vista. Check which version of PGF package you have (I have pgf 2.00), from the error messages it looks like it might be some older one.
Cheers,
Tomek
Re: Graphics in latex
I don't know why I wrote ted earlier, well i really don't know.
Thanks for the reply Tomek, can you tell me how can i know the version pgf i'm using , and where can i get the latest version -pgf 2.00. from ?
Thank you once again for the help.
metric
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Graphics in latex
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Graphics in latex
To increase your appetite for pgf/tikz here's the code for the other part of your drawing.
Code: Select all
\begin{tikzpicture}[>=latex,inner sep=0.3ex]
\def\vlen{5}
\def\wlen{3}
\def\angAlpha{15}
\def\angBeta{50}
\coordinate (o) at (0,0);
\coordinate (v) at (\angAlpha:\vlen);
\coordinate (w) at (\angBeta:\wlen);
\node[below left=0.5ex] (O) at (o) {$O$};
\draw[->] (0,-1em) -- (0,\wlen) node[above] {$y$};
\draw[->] (-1em,0) -- (\vlen,0) -- +(1em,0) node[right] {$x$};
\draw[->,thick] (o) -- (v) node[right] {$v = (v_1,v_2)$} node[pos=0.6,above left] {$\lVert v \rVert$};
\draw[->,thick] (o) -- (w) node[above right] {$w = (w_1,w_2)$} node[midway,above left] {$\lVert w \rVert$};
\draw[->,thick] (w) -- (v);
\draw[very thin] (w |- o) -- (w) (v |- o) -- (v);
\def\radius{4em}
\draw[->,thin] (2:\radius) node[above right] {$\alpha$} (\radius,0) arc (0:\angAlpha:\radius);
\def\radius{3em}
\draw[->,thin] (25:\radius) node[above right] {$\beta$} (\radius,0) arc (0:\angBeta:\radius);
\def\radius{1.5em}
\draw[->,thin] (25:\radius) node[above right] {$\theta$} (\angAlpha:\radius) arc (\angAlpha:\angBeta:\radius);
\end{tikzpicture}
Tomek