How to Draw Equations with Parameter Description in Latex using Tikz
I was looking for a code that has a visualization of equation parameter description like the following.
Then I found this awesome collection of Tikz Examples and I just modified a little from their code.
First, we need the following packages:
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{xcolor}
Now, here’s the code that produces this output. You can also check out the output in this overleaf project.
\def\hd{0.5}
\def\vd{0.5}
\newcommand{\tm}[1]{\tikz[overlay, anchor=base] \node[red] (#1) {};}
\tikzstyle{every picture}+=[remember picture]
\begin{tikzpicture}[
>=stealth,
every path/.style={->, color=green!70!white, thin, rounded corners},
every node/.style={color=black},
bx/.style={text width=3cm, font=\footnotesize, minimum height=4ex},
bxl/.append style={bx, left, align=flush right},
bxr/.append style={bx, right, align=flush left}]
\node {
$\tm{y}y =
\tm{b0}\beta_0+
\tm{b1}\beta_1
\tm{x1}x_1+
\tm{b2}\beta_2
\tm{x2}x_2+\cdots+
\tm{bk}\beta_k
\tm{xk}x_k+
\tm{er}\epsilon$
};
\node[bx, align=center] (preds) at (0.4,1.5)
{Independent Variables};
\node[bx, align=center] (tx) at (0.4,-1.5) {Coefficients};
\path[draw] (y)+(0.5ex,2ex) to[out=90, in=0] +(-\vd,\hd)
node[bxl] {Dependent variable};
\path[draw] (x1)+(0.5ex,2ex) to[out=90, in=-90] (preds);
\path[draw] (x2)+(0.5ex,2ex) to[out=90, in=-90] (preds);
\path[draw] (xk)+(0.5ex,2ex) to[out=90, in=-90] (preds);
\path[draw] (b1)+(1ex,-1ex) to[out=-90, in=90] (tx);
\path[draw] (b2)+(1ex,-1ex) to[out=-90, in=90] (tx);
\path[draw] (bk)+(1ex,-1ex) to[out=-90, in=90] (tx);
\path[draw] (b0)+(1ex,-1ex) to[out=-90, in=0] +(-\vd,-\hd)
node[bxl] {Intercept};
\path[draw] (er)+(0.5ex,-1ex) to[out=-90, in=180] +(\vd,-\hd)
node[bxr] {Random Error};
\end{tikzpicture}
Latex-related Posts
You can find a comprehensive list of Latex resources in the following post:
If you are a new Latex user, check out this post: 20 Most Common Mistakes Made by New Latex Users
You can find all Latex
oriented posts of mine in: https://shantoroy.com/categories/#latex
- How to write an algorithm in Latex
- How to add subfigure in Latex
- Add Copyright Notice and Conference Name in IEEE Conference Template
- Preparing Tables for Publication and Documentation in Latex
- How to Write Matrix with Row/Column Labels in Latex
- How to Collaboratively Write a Paper using Overleaf Latex Platform
- Itemize, Enumerate, and To-do-list in Latex
- Latex Table for Survey in IEEE two-column format
- Line Plotting using Latex PGFPlots
- How to Create Bar Charts using Latex PGFPlots
- How to add Codes in Latex:
listings
package for code documentation - Bibliography management with Bibtex in Latex
- Creating Multiple Line plots from CSV file using Latex Tikz and PGFPlot
- How to Draw a Literature Survey Taxonomy Tree in Latex
- How to Convert Python Matplotlib Plots to Latex Plots (Easiest Way) for Academic Papers
Leave a comment