Underline Math Formula in LaTeX
In this tutorial, I am going to show you how to underline math formulas in LaTeX math mode. LaTeX already comes with the built-in \underline
command that we can use to give underline to our math equations or formulas in LaTex.
In the example below, we are using the \underline
method to underline LaTeX math:
\[ \underline{E = mc^2} \]
Below is the complete document command:
\documentclass{article} \begin{document} This is an underlined math equation: \[ \underline{E = mc^2} \] \end{document}
You can see that we have not included any package. This is because it doesn’t need to include anything as this is already built-in in default.
Alternatively, you can use the \tikz
package to underline your LaTeX math formulas. This package gives you more advanced features like colored underlines or thicker lines. In order to use this package, you also have to use the amsmath
package.
Below is an example where we set the underlined color to blue:
\[ \text{\tikz[baseline={(char.base)}]{ \node[anchor=base] (char) {$E = mc^2$}; \draw[thick,blue] (char.south west) -- (char.south east); }} \]
below is given the complete document code:
\documentclass{article} \usepackage{amsmath} \usepackage{tikz} \begin{document} An equation with a customized and colored underline using tikz: \[ \text{\tikz[baseline={(char.base)}]{ \node[anchor=base] (char) {$E = mc^2$}; \draw[thick,blue] (char.south west) -- (char.south east); }} \] \end{document}
Leave a Reply