How can I use texdraw to create diagrams in LaTeX?

In summary, Texdraw is a tool that allows users to easily create diagrams in LaTeX. This can be done by using specific commands and packages, as well as a graphical user interface. Texdraw offers a wide range of features and customization options, making it a versatile and efficient tool for creating diagrams in LaTeX documents. With its simple syntax and compatibility with various LaTeX compilers, Texdraw is a valuable resource for those looking to incorporate visually appealing diagrams in their documents.
  • #1
EngWiPy
1,368
61
Hello,

How can I draw the following figure using latex?

attachment.php?attachmentid=20450&stc=1&d=1252317887.jpg

Thanks in advance
 

Attachments

  • Relay.JPG
    Relay.JPG
    4.8 KB · Views: 1,173
Physics news on Phys.org
  • #2
Hi there,

Do you desperately want to draw a picture in LaTeX? If so, you can always do it in the figure environment: \begin{figure} \end{figure}. From this environment, you will need to tell LaTeX what, where, and how each piece of the drawing should be placed. As you can imagine, even for a very small figure, you need to add many, many, many commands, which become terribly cumbersome.

I suggest you to use a drawing environment, like gimp or xfig (opensource), to draw your pciture. Then you simply need to include it in your text wherever you want to. I believe you will save a lot of time and effort.

Cheers
 
  • #3
fatra2 said:
Hi there,

Do you desperately want to draw a picture in LaTeX? If so, you can always do it in the figure environment: \begin{figure} \end{figure}. From this environment, you will need to tell LaTeX what, where, and how each piece of the drawing should be placed. As you can imagine, even for a very small figure, you need to add many, many, many commands, which become terribly cumbersome.

I suggest you to use a drawing environment, like gimp or xfig (opensource), to draw your pciture. Then you simply need to include it in your text wherever you want to. I believe you will save a lot of time and effort.

Cheers

There are figures (.eps files) that I must add them using the figure enviroment, and I already did. But I want to draw schematic diagrams to illustrate something like the figure I attached in the first post. I have downloaded the pgf package, but I don't know where to start, its manual quite long and doesn't give you things in direct way, where I have to deliver my thesis soon.

Regards
 
  • #4
S_David said:
I have downloaded the pgf package, but I don't know where to start, its manual quite long and doesn't give you things in direct way, where I have to deliver my thesis soon.

That is the problem with drawing directly in LaTeX: it's quite long. On top of it, you will have to compile very often, to see the output result of your picture, which will consume more time.

To answer your question simply, the only I made drawing directly in LaTeX is by reading part of the manual (the one that could be necessary for you). Try and see the output result. I am sure that when you get to know the package, you can come up with decent results in no time. But at first, and specially if you are in a bit of hurry, I suggest you look into something like xfig (Winfig for MS Windows). You will be able to make this drawing, and save it into a .eps file.

Cheers
 
  • #5
  • #6
The following code will draw the figure you want using the pgf/TikZ package that you downloaded:
Code:
\documentclass[12pt]{article}
\usepackage{tikz}

\begin{document}

\begin{figure}
\begin{center}
\begin{tikzpicture}
    % draw nodes (pgf/TikZ v2.00 manual sections 3.4, 3.7, 3.9)
    \node (source) at (0,0) [circle,draw,label=below:Source] {$S$};
    \node (relay) at (3,2) [circle,draw,label=below:Relay] {$R$};
    \node (destination) at (6,0) [circle,draw,label=below:Destination] {$D$};
	
    % connect nodes (pgf/TikZ v2.00 manual section 3.11)
    \draw [->] (source.60) to node [auto] {$\alpha_1$} (relay.west);
    \draw [->] (relay.east) to node [auto] {$\alpha_2$} (destination.120);
    \draw [->] (source.east) to node [auto,swap] {$\alpha_0$} (destination.west);
\end{tikzpicture}
\end{center}

\caption{\label{fig:SRD} Source-relay-destination figure.}
\end{figure}

\end{document}
attachment.php?attachmentid=20521&stc=1&d=1252724521.png
 

Attachments

  • tikz.png
    tikz.png
    6.8 KB · Views: 1,311
Last edited:
  • #7
That is fantastic las3rjock. Actually, I drew it previousely, but this code has more flexibility.

Thank you
 
  • #8
That's just the kind of problem that I wrote my own code generator for. It's a java applet, you can see it on my homepage at http://artsci.wustl.edu/~jplate/pasi.html#applet_section .

To draw your diagram, you just need to do these basic steps:

0. Add "\usepackage{texdraw}" to your preamble.
1. Create the 3 nodes (shift-click on three locations on the screen, then click "Add Node").
2. Create the arrows (shift-click on two or more nodes, then select a kind of arrow in the menu on the right and click on "Create").
3. Create labels for the nodes (select all nodes, e.g., by 'lassoing'; select "Label" in menu'; click on "Create" twice, to create two labels for each node).
4. Fill in the text for the labels (select the labels individually, then enter text in the text area on the right).
5. "Center" the labels that should be centered (you can do that for each one individually or for all three in one go, viz, if you select all three of them first).
6. To place an existing label *below* the respective node, set the "Preferred Angle" to -90.
7. Create labels for the arrows: first select the arrows, then create and edit labels in the same way as for nodes. (This will make additional nodes appear that are centered on the arrows. You can make these invisible by scrolling down to "Node Properties" and setting "Line Width" to 0.)
8. Once you're done editing, click on "Generate" and copy the code into your latex file (surrounded by "\begin{figure}\begin{center}...\end{center}\end{figure}"). (If this doesn't work directly, use the "To Webpage" button, which will send the text to the web page. From there, you'll always be able to copy the generated text.)

Note that you'll be able to adjust the positions of the nodes even after you've created the diagram; the arrows and labels will stay connected to them. Also, note that you won't have to do any cropping, since texdraw takes care of this itself.
 
Last edited by a moderator:

1. How do I draw figures in LaTeX?

To draw figures in LaTeX, you can use the \includegraphics command. This command allows you to insert an external image file into your document. You can also use packages like tikz or pstricks to create figures directly in LaTeX.

2. How can I resize a figure in LaTeX?

To resize a figure in LaTeX, you can use the \includegraphics command with the width or height option. For example, \includegraphics[width=0.5\textwidth]{image.jpg} will resize the image to half of the text width. Alternatively, you can use the \scalebox command to resize the figure by a specific scaling factor.

3. What is the best format for figures in LaTeX?

The most commonly used format for figures in LaTeX is .eps (Encapsulated PostScript) as it allows for high-quality vector graphics. However, you can also use other formats such as .pdf, .png, or .jpg. It is recommended to use vector graphics whenever possible to maintain the quality of the figure when resizing.

4. How do I add captions to figures in LaTeX?

To add captions to figures in LaTeX, you can use the \caption command within a figure environment. You can also use the \label command to add a label to your figure, which can be referenced later in the text using the \ref command.

5. Can I draw diagrams or graphs in LaTeX?

Yes, you can draw diagrams and graphs in LaTeX using packages like tikz, pstricks, or pgfplots. These packages offer a wide range of options for creating various types of diagrams and graphs, such as flowcharts, Venn diagrams, bar graphs, and more.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
254
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
794
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
938
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
23
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
936
Back
Top