General ⇒ Graphics in latex
Graphics in latex
Hi,
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.
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 7941 times
NEW: TikZ book now 40% off at Amazon.com for a short time.

Graphics in latex
See this fresh thread. Some options for keeping textual content of the graphic in the same style as in the body of your document are mentioned there.
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
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¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Graphics in latex
Here is some tikz code and the resulting image. That should get you halfway.
Cheers,
Tomek
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 7919 times
Re: Graphics in latex
I would like to thanks all of you for helping me out with this. I'll try out these methods, hope it will make my work easier,
Thank you once again for the help.
metric
Thank you once again for the help.
metric
Re: Graphics in latex
Hi Ted,
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
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
Hi Arif,
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
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
Hi Tomek,
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
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
Put the \listfiles command as first line of your code. Start at least one run and take a look at the log file. There you will find a section beginning with *File List* and ending with *********** which lists all used packages with their version numbers. Since you are using MiKTeX you can get the current version of pgf by updating your system (Start -> Programs -> MiKTeX -> Update). Make sure that you haven chosen a server in your country.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Graphics in latex
Arif,
To increase your appetite for pgf/tikz here's the code for the other part of your drawing.
And this is how the output looks like:
Cheers,
Tomek
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