How to Write Math Equation in LaTeX

I am new in LaTex and need your help to write the following math equation in LaTeX.

• Welcome to TeX.SX! What have you done so far? Try H_{k_p}=\frac{Y_{k_p}}{X_{k_p}} – Bobyandbob Oct 3 '18 at 16:50
• Comment not at all an answer. ff you can conveniently write what you mean without using double subscripts many readers will find it easier to understand you. – Ethan Bolker Oct 3 '18 at 23:28

One of the simplest ways to input an equation into LaTeX is to write something like

\documentclass{article}

\begin{document}

$$H_{k_p}=\frac{Y_{k_p}}{X_{k_p}}$$

\end{document}


Notice how I've used the syntax of LaTeX to format the equation into the way you want - subscripts need the _ key, and I've used { } to indicate "k_p" should itself be a subscript. Also note how to make fractions by using the \frac{}{} command.

• You can mark inline code as such by using back ticks: . – Skillmon Oct 3 '18 at 16:56

A very simple one. You can use one of the three methods below (among others…)

Edit

Use \frac instead of \dfrac

\documentclass{article}

\usepackage{amsmath}

\begin{document}
In displaystyle
$H_{k_{p}}=\frac{Y_{k_{p}}}{X_{k_{p}}}$

Or inline $H_{k_{p}}=\dfrac{Y_{k_{p}}}{X_{k_{p}}}=\frac{Y_{k_{p}}}{X_{k_{p}}}=\tfrac{Y_{k_{p}}}{X_{k_{p}}}$.

With a numbered and refenced equation (see \ref{eq:1})
$$H_{k_{p}}=\frac{Y_{k_{p}}}{X_{k_{p}}}\label{eq:1}$$
\end{document}


• Why do you use \dfrac? With normal \baselineskip this is likely to be too large in inline maths (and in your displayed equation it is the same as \frac). – Skillmon Oct 3 '18 at 16:55
• Only because I made a copy/paste… :( Answer edited. – NBur Oct 3 '18 at 16:57
• @Skillmon However, in inline mode with \frac or \tfrac, I dislike the numerator touching the line… – NBur Oct 3 '18 at 17:05
• Use the following MWE and you'll instantly see why using \dfrac is a bad idea without additional line spread (in fact even a \frac is too large here): \documentclass{article}\usepackage{amsmath,duckuments}\begin{document}\blindduck$H_{k_{p}}=\dfrac{Y_{k_{p}}}{X_{k_{p}}}$\blindduck\par \blindduck$H_{k_{p}}=\frac{Y_{k_{p}}}{X_{k_{p}}}$\blindduck\end{document}`. – Skillmon Oct 3 '18 at 17:11
• Also the numerator doesn't touch the line, that's the fault of your pdf viewer. – Skillmon Oct 3 '18 at 17:12