[Tex/LaTex] Align an array horizontally to the center of the page

arrayshorizontal alignment

I am trying to make an array align to the center of the page.

My search for the answer was fruitless as all of the questions (that I have find) refer to the alignment of the array elements and not the array itself.

I have tried using the center environment but didn't work. Also the same happened with the command \centering that I came across (although I may have used it wrong).

So how can I center the array to the center of the page?

\documentclass[12pt]{article}

\usepackage{parskip}

\setlength{\parindent}{0cm}

\usepackage{fontspec}

\usepackage[english,greek]{babel}

\usepackage[fleqn]{amsmath}

\usepackage{unicode-math}

\usepackage{listings}

\setmainfont
[
  Ligatures=TeX,
  Extension=.otf,
  UprightFont=*,
  BoldFont=*Bold,
  ItalicFont=*It,
  BoldItalicFont=*BoldIt,
  Mapping=tex-text
]{GFSArtemisia}

\setsansfont[Mapping=tex-text]{GFSArtemisia.otf}

\setmathfont{latinmodern-math.otf}

\setmathfont[range=\varnothing]{Asana-Math.otf}

\setmathfont[range=\int]{latinmodern-math.otf}

\begin{document}

\begin{equation*}
\begin{array}{cc}
1 & 2\\
3 & 4
\end{array}
\end{equation*}

\end{document}

Best Answer

Leaving only the essential parts:

\documentclass[12pt]{article}

\usepackage[fleqn]{amsmath}

% these two packages are only for the example
\usepackage{showframe}
\usepackage{lipsum}

\newenvironment{centermath}
 {\begin{center}$\displaystyle}
 {$\end{center}}


\begin{document}

\lipsum*[2]
\begin{equation}
\int_{0}^{x}\frac{1}{t}\,dt=\log t
\end{equation}
\lipsum*[2]
\begin{centermath}
\begin{array}{cc}
1 & 2\\
3 & 4
\end{array}
\end{centermath}
\lipsum[3]

\end{document}

enter image description here

Related Question