# Align an array horizontally to the center of the page

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}

• Remove the fleqn option? By the way, amsmath should be loaded before fontspec. – egreg Dec 29 '14 at 23:21
• @egreg thank you for your suggestion, but that changes the position of everything and not only of the array. I want the equations to remain in the left side of the page. I know about the amsmath, you have told me that in the past and I use it always! in this case I just copied and pasted some fragments of my preamble and that's why it is loaded after fontspec. :) – Adam Dec 29 '14 at 23:25
• But you've put the array inside equation* so fleqn says you want it flush left... – cfr Dec 29 '14 at 23:32
• @cfr yes but the fleqn option is global so there must be a way to change only one element (the array in this instant). – Adam Dec 29 '14 at 23:35
• @cfr also I just used the equation enviroment out of habbit, it doesn't need to be that. Check egreg's answer. :) – Adam Dec 29 '14 at 23:37

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]
$$\int_{0}^{x}\frac{1}{t}\,dt=\log t$$
\lipsum*[2]
\begin{centermath}
\begin{array}{cc}
1 & 2\\
3 & 4
\end{array}
\end{centermath}
\lipsum[3]

\end{document}