1

I am writing a project report, where I have been asked to plot the figure using tikz in overleaf. I made the figure on Powerpoint Presentations (PPT) and then imported it on my overleaf using pdf format. Which actually is very high quality.

But I have still been asked to re-plot using tikz plots. I want to ask, is there any major difference between what I have done and what I will get using tikz? Additionally, is it possible to plot this figure?

Kindly someone, suggest how to go about this figure. I was not able to generate the boxes with proper spacing. I don't have any experience using tikz.

enter image description here

I tried making some of the parts of the figure using help from online websites; but could not figure out how to place them as given in the picture or how to exactly make them like the picture.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz, pgfplots}
\usetikzlibrary{positioning}
\usepackage{geometry,graphicx}
\usepackage{tikz,amsmath}

\usetikzlibrary{fit}

\begin{document}

\vspace{2in}

\begin{tikzpicture}[ SIR/.style={rectangle, draw=black!60, fill=white!5, very thick, minimum size=5mm}, ] %Nodes \node[SIR] (Susceptible) {X X X X X}; \end{tikzpicture}

Computation domain\

\begin{tikzpicture} \node[draw,minimum size=1.5cm] (A) at (0,0) {Equation at $x_1$}; \end{tikzpicture}

\begin{tikzpicture} \node[draw,minimum size=1.5cm] (A) at (0,0) {$x_2 - x_1$ extra integral}; \end{tikzpicture}\

% Preamble: \pgfplotsset{width=7cm,compat=1.3} \begin{tikzpicture} \begin{axis}[ xlabel=Quad point, ylabel={Numerical error} ] % use TeX as calculator: \addplot {e^-x+50}; \end{axis} \end{tikzpicture}

\end{document}

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 16 '23 at 05:46
  • (off-topic) You can try changing the font in PowerPoint to use TeX's default font (Latin Modern), see if they complain. The output should look roughly the same with that. – user202729 Jan 16 '23 at 06:55
  • @user202729 I couldn't find such font last time I used that soft. Can it also use the TeX spacing algorithms? Otherwise output wouldn't look so much the same. – gildux Jan 16 '23 at 08:37
  • @gildux Spacing algorithm cannot be used (unless you compile individual paragraphs in TeX then include in PowerPoint as image). For the font you need to install yourself. See also formatting - Make MS Word document look like it has been typeset in LaTeX - TeX - LaTeX Stack Exchange – user202729 Jan 16 '23 at 08:40
  • @Community I have updated the question, may you kindly remove the downvote. – Formal_this Jan 16 '23 at 16:27
  • Thanks @user202729 Nice to know about this font use inside ms world. – gildux Jan 16 '23 at 21:24
  • Welcome TeX.SE @Formal_this I think the downvote was because your question isn't focus plus not having a MWE to help us help you. Your edit makes things better now. However, comments can't be edited after some amount of time, and same for votes. As I didn't vote on the question yet ('cause I avoid downvoting on already negative scored items) I'll vote up to compensate. Regards. – gildux Jan 16 '23 at 21:30
  • @gildux thanks for the advice note, I'll remember – Formal_this Jan 16 '23 at 22:48

2 Answers2

4

For sure it's possible to draw (almost?) everything with TikZ. Have a look at http://texample.net/tikz/examples/all/ for instance.

Pros

  • homogeneity with the whole document (particularly fonts…)
  • no third party elements

Cons

  • it may take (a lot of) time depending on your TikZ skills and on the graph to plot…
  • compilation time would increase (even if you can use the externalize functionality)
NBur
  • 4,326
  • 10
  • 27
3

To give you some ideas:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}

\begin{scope}[scale=0.75] \draw[blue!50!black] plot[domain={-1.5:5}] (\x,{e^-\x-1}); \draw[blue!50!black, densely dotted] (-2,0) -- (5,0); \draw[black, densely dashed] (0,0) -- ++(0,-2) node[below] {$x_1$} coordinate[pos=0] (A); \draw[black, densely dashed] (2.5,0) -- ++(0,-2) node[below] {$x_2$} coordinate[pos=0] (B);

\draw[draw, thick, ->] ([yshift=5pt]A) 
    to[out=90, in=90, looseness=1.75] 
    node[above, midway, xshift=25pt] {Increase in quad. points} ([yshift=5pt]B);

\draw[thick, <->] (-2,4) 
    -- node[left, midway, anchor=south, rotate=90, font=\bfseries] (Y) {Numerical error} (-2,-2)
    -- node[below, pos=1, font=\bfseries] {Quad. points} (5,-2);

\end{scope}

\node[draw=blue!50!black, fill=yellow!25, text width=3cm, align=center] at ([yshift=-3cm]$(A)!0.5!(B)$) (E) {Equations at $x_1$};

\draw[thick, ->] ([yshift=-2cm]$(A)!0.5!(B)$) -- ([yshift=5pt]E.north);

\node[draw=blue!50!black, fill=yellow!25, text width=3cm, align=center, below=10pt of E] (F) {$(x_2 - x_1)$ \ \textbf{Extra integrals}};

\draw[decorate, decoration={brace, mirror, raise=2.5pt, amplitude=5pt}] (E.north west) -- (F.south west) node[left, midway, anchor=south, rotate=90, yshift=5pt, font=\bfseries] {Equations at $x_2$};

\matrix[matrix of nodes, draw, nodes={circle, inner sep=2pt, font=\bfseries}, row sep=10pt] (M) at (-5,-2) { X & X & X & X & |[fill=cyan!25, draw]| X \ X & X & X & X & X \ X & X & X & X & X \ };

\draw[thick, ->] (M-1-5) -- ([yshift=20pt]Y.north west);

\node[below=2.5pt of M] {Computation domain};

\end{tikzpicture}

\end{document}

enter image description here

  • Oh, that's amazing. How were you able to do that so fast? May you kindly guide me to the resources which you have used to develop this fluency in tikz? – Formal_this Jan 16 '23 at 16:31
  • 1
    @Formal_this The main resource is probably the TikZ/PGF manual which contains a lot of examples as well as in-depth information about how to use it. You will become more and more fluent with creating more and more things using TikZ. It might seem overwhelming in the beginning, but it is actually well-structured and therefore not too hard to learn. – Jasper Habicht Jan 16 '23 at 16:39
  • Okay, thanks a lot for the help. Also, may you kindly remove the downvote from my post. – Formal_this Jan 16 '23 at 16:45
  • 1
    @Formal_this I did not downvote (and gave you an upvote now). Now that you provided an MWE, your question is already quite okay. Maybe you can specify a bit more which problems you had, for example, you could put the focus of your question on how to combine the three parts of the illustration into one complex diagram. This would make it a bit more suitable for this site where questions are normally meant to focus on a specific problem. I assume that the fact that your question is not very focused is the reason for the downvotes. – Jasper Habicht Jan 16 '23 at 16:59
  • Okay, thanks for the advice. And the upvote. – Formal_this Jan 16 '23 at 21:25