1

I'm having a bad time trying to figure out how to place Example 1 in the left and the math material one line below and centered. How do I do that?

\documentclass[10pt,a4paper]{article}

\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\newtheorem{xmp}{Example}

\begin{document}
    \begin{xmp}
        $ \mathbf{A}_{4\times 4}=\begin{pmatrix}
        5 & -2 & 4 & 7 \\
        -1 & 3 & 0 & -6 \\
        2 & -9 & 5 & 8 \\
        0 & 3 & 4 & 1
        \end{pmatrix} $
    \end{xmp}
\end{document}
Mico
  • 506,678
Levy
  • 1,167
  • 1
    some reading of basic latex documentation would be useful. regarding math, i recommend documentation for amsmath and mathtools. – barbara beeton Jul 31 '18 at 12:52

1 Answers1

4

Like this? Replace your dollar signs $ with \[ and \] to format your equation in display mode.

For further reading see What are the differences between $...$, $$...$$, \(...\), and \[...\]?

enter image description here

\documentclass[10pt,a4paper]{article}

\usepackage{amsmath}
\newtheorem{xmp}{Example}

\begin{document}
    \begin{xmp}
    \[
        \mathbf{A}_{4\times 4}=\begin{pmatrix}
        5 & -2 & 4 & 7 \\
        -1 & 3 & 0 & -6 \\
        2 & -9 & 5 & 8 \\
        0 & 3 & 4 & 1
        \end{pmatrix} 
    \]
    \end{xmp}
\end{document}
Milo
  • 9,440
  • 2
    +1. To improve the readability of the contents of the 4x4 matrix, you may want to recommend that the OP load the mathtools package (a superset of the amsmath package) and replace (a) \begin{pmatrix} with \begin{pmatrix*}[r] and (b) \end{pmatrix} with \end{pmatrix*}. That way, the numbers will be right-aligned instead of centered, greatly improving the overall appearance and readability of the matrix. – Mico Jul 27 '18 at 05:32
  • Thank you very much both of you. It solved my problem and it got much better looking. – Levy Jul 27 '18 at 14:07