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}
  • gather* works if you remove those & before =, for example, C_{12}x = (Y1 * Z2 - Z1 * Y2)\\ – user11232 Mar 27 '15 at 0:21
  • Should the text be centered as well, or just the math material? – Mico Mar 27 '15 at 1:21
  • this appears to be a follow-on to How do you center everything. it's usually appreciated if that is noted in the newer question. – barbara beeton Mar 27 '15 at 13:13
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.

  • Well, the textual parts should be fixed, shouldn't they? – egreg Mar 27 '15 at 0:28
  • @egreg I thought they are just for demo. Fixed. – user11232 Mar 27 '15 at 0:40
  • One last question: How do you put in a single space in LaTeX? – user1531503 Mar 27 '15 at 0:42
  • @user1531503 Single space where? Please read: What commands are there for horizontal spacing? – user11232 Mar 27 '15 at 0:43
  • 4
    @user1531503 And please also read: How do you accept an answer :) – user11232 Mar 27 '15 at 0:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.