# [Tex/LaTex] How to center a multiline equation?

equationsknitrpandoc

I want to center multi row equationing but all my attemts won't work. I'm working with pandoc/knitr of Rmarkdown. I show you an example:

\begin{aligned} <!-- \begin{center} --> \label{eq1} x_1 = 1, x_2 = 1 \\ h(x) = f(-20 + 15 + 17) \\ h(x) = f(12) \approx 1 \\ <!-- \end{center} --> \end{aligned}
\end{aligned}



When I use center, I get this error:

! Missing $inserted. <inserted text>$
l.100 \begin{center}


Thanks for any help.

Use a gathered environment inside the equation environment:
\documentclass{article}
$$\label{eq1} \begin{gathered} x_1 = 1, x_2 = 1 \\ h(x) = f(-20 + 15 + 17) \\ h(x) = f(12) \approx 1 % no "\\" needed here \end{gathered}$$