1

I have a somewhat working LaTeX program written. One thing I would like to be better is the centering of the \begin{align*}...\end{align*}.

I tried \begin{gather*}...\end{gather*} but I can not get it to work with heavy math Latex code just text.

I would also like to know the Latex code for a single space.

Here is my code:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\centering
\begin{gather*}
Given:\\
3 consecutive R vectors.\\
\\
Find:\\ 
Middle Velocity vector and Keplerian Elements.\\
\\
Solution:\\
\end{gather*}
\begin{align*}
R1=(X1,Y1,Z1)\\
R2=(X2,Y2,Z2)\\
R3=(X3,Y3,Z3)\\
C_{12} &= R1 \times R2 = \begin{vmatrix}%
    \hat{x}& \hat{y}& \hat{z}\\
     X1&Y1&Z1\\
     X2&Y2&Z2\\
\end{vmatrix}\\
C_{12}x &= (Y1 * Z2 - Z1 * Y2)\\
C_{12}y &= (Z1 * X2 - X1 * Z2)\\
C_{12}z &= (X1 * Y2 - Y1 * X2)  
\end{align*}
\end{document}
David Carlisle
  • 757,742

1 Answers1

4

You have to use gather* without the alignment point, i.e., remove those & before =. There is no point in aligning when you want every thing to be centered.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\centering
Given:

3 consecutive R vectors.

Find:

Middle Velocity vector and Keplerian Elements.

Solution:
\begin{gather*}
R1=(X1,Y1,Z1)\\
R2=(X2,Y2,Z2)\\
R3=(X3,Y3,Z3)\\
C_{12} = R1 \times R2 = \begin{vmatrix}%
    \hat{x}& \hat{y}& \hat{z}\\
     X1&Y1&Z1\\
     X2&Y2&Z2\\
\end{vmatrix}\\
C_{12}x = (Y1 * Z2 - Z1 * Y2)\\
C_{12}y = (Z1 * X2 - X1 * Z2)\\
C_{12}z = (X1 * Y2 - Y1 * X2)
\end{gather*}
\end{document}

enter image description here

For more on horizontal spaces, read this answer by Werner.