Graphics, Figures & TablesTools and best Practice for Diagrams

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sachinrajsharma
Posts: 35
Joined: Sun Apr 08, 2012 5:48 am

Tools and best Practice for Diagrams

Post by sachinrajsharma »

Hi,

I have been using LaTeX for the past two years and find it best for my mathematical research documentation. However, when it comes to drawing various diagram I am facing lot of problem. As it takes too much of time while making diagrams in latex. For that I have downloaded LaTeXDraw, and in that I am feeling more comfortable to draw various diagrams. But the issue which I am facing is that how to insert these diagrams (coding) in my source code. I have done the following efforts for making diagrams.
  1. I have used pgf/TikZ (found it more time consuming). However, I have made diagrams like triangle, circles etc. in it in more easier way.
  2. I have also used pstricks.
  3. Because I was unable to make these diagrams, then I started doing scan of these diagrams and inserted in my documentation but print out of these documents were not clear and I was not satisfied.
  4. I downloaded LaTeXDraw (which I have already mentioned)
Is there any way so that I can save my time by making diagrams in more easier way like using Latex draw and insert the same in the my mathematical research document. I have typed lot many equations and matter during the past two years but this is the only problem I am facing in LaTeX.

Request you to please guide, I will be grateful to you.

Regards,
Sachin Sharma

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Tools and best Practice for Diagrams

Post by Johannes_B »

What kind of diagrams are you creating? Simple diagrams can be edited and viewed using PGF/TikZ or PSTricks and an editor. Some people are more comfortable with those little editors.

As you already mentioned, there is LaTeXDraw. As far as I know, it supports the export of PSTricks code (which it uses internally) so you could just \input this code into your document. This would be similar to the way you are producing PSTricks pictures by hand. The export of PDF is possible, too. So you could put the PDF into your document using \includegraphics.

Jpgfdraw is similar to LaTeXDraw, but it uses TikZ instead. But the inclusion into your document would be the same.

Do you know the pgfplots package? This is very suitable if you want to plot some data.

If you need more help, please be aware to post a Minimal Working Example which helps us to verify the problem and help you faster.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
sachinrajsharma
Posts: 35
Joined: Sun Apr 08, 2012 5:48 am

Tools and best Practice for Diagrams

Post by sachinrajsharma »

Hi,

Thanks for your reply, however I have two questions here.
  1. What is the use of LaTeXDraw, if we can't insert it's coding directly in a document?
  2. I have downloaded Jpgfdraw (ZIP file), I am unable to install this. Please help on this but before that please let me know whether I will be able to insert the coding of the output of diagrams of this in the document, if not then I think it will be of no use to me.
Below I add a code sample of LaTeXDraw for which I am unable to get the output in my document (this question I have raised in forum, but didn't get satisfactory answer).

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \draw[help lines] (-2,0) grid (2,4); 
    \draw[->] (-2.2,0) -- (2.2,0); 
    \draw[->] (0,0) -- (0,4.2); 
    \draw[green, thick, domain=-2:2] plot (\x, {4-\x*\x}); 
    \draw[domain=-2:2, samples=50] plot (\x, {1+cos(pi*\x r});
  \end{tikzpicture}
  \begin{tikzpicture}[domain=0:4] 
    \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
    \draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$}; 
    \draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
    \draw[color=red]    plot (\x,\x)             node[right] {$f(x) =x$}; 
    \draw[color=blue]   plot (\x,{sin(\x r)})    node[right] {$f(x) = \sin x$}; 
    \draw[color=orange] plot (\x,{0.05*exp(\x)}) node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
  \end{tikzpicture}
\end{document}
Thanks for all of your support.

Regards,
Sachin Sharmaa
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Tools and best Practice for Diagrams

Post by Johannes_B »

Concerning your first question: LaTeXDraw generates PSTricks code, shown on the right side of the window (at least on my machine). You can just copy&paste all this code into your LaTeX file, or export as as an ASCII text with the ending .tex. This makes it possible for you to \input the file (which is equivalent to copy&paste) and not getting confused with the shown code (it can be very long for complicated pictures).

(Almost) the same works for Jpgfdraw, but the generated code is PGF, the back-end of TikZ.

Installation directions are given on the Jpgfdraw homepage. You did not tell us what system you are using or if/what error occurs. Please be more specific.

I don't understand your last question, this is a perfectly fine minimal example. You can compile it using pdflatex. In order to include it into your document you need to delete lines which are not needed or allowed, meaning the whole preamble/everything but the tikzpicture environment.

You could also change the document class to minimal, compile the PDF and include the PDF into your document.

In order to help you we need precise information on what your trying to do or trying to accomplish.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Tools and best Practice for Diagrams

Post by localghost »

sachinrajsharma wrote:[…] Below I add a code sample of LaTeXDraw for which I am unable to get the output in my document (this question I have raised in forum, but didn't get satisfactory answer). […]
If the answer to your other question was not satisfactory, you should ask follow-up questions. But giving feedback to proposed solutions has never been one of your qualities since you are a member here.

I recommend not to rely on bad export of third party tools but learn how to use one of the packages mentioned here. This is no sorcery. The packages have very good manuals. At the moment you have time consuming problems with those tools, too. Hence there is no benefit.

If you run into trouble, ask targeted questions here in the forum and learn to discuss problems with others in order to solve them. Your poor feedback is the main cause for unsatisfactory answers to your questions.


Thorsten
Post Reply