0

I want to center this following code:

\documentclass[12pt,fleqn]{article}
\usepackage{bm}
\usepackage{amsmath}
\usepackage[overload]{empheq}

\newcommand*\widebox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}
\newcommand*\rpos{\text{\textbf{r}}}

\begin{document}
    \begin{empheq}[box=\widebox]{align}
    \rpos&=x\,\hat{i}+y\,\hat{j}+z\,\hat{k},\nonumber\\
    \mathbf R &= (R_{\text{Terra}}+\text{h})\:\hat{k},\nonumber\\
    \bm{\mathcal R}&=\mathbf R + \rpos,\nonumber\\
    \bm{\omega}&=\omega(sin\lambda\:\hat{i}+cos\lambda\:\hat{k}).\nonumber\\ \nonumber
    \end{empheq}
\end{document}

Result

Any ideas?

7
  • 1
    Do you want the code centered in the box, or do you want the box centered across the line. p.s. Your code does not compile as is...please edit to make it compile. Welcome to the site. Oct 13, 2016 at 11:26
  • 1
    Remove the last \\ \nonumber to center the equations vertically in the box.
    – gernot
    Oct 13, 2016 at 11:39
  • 1
    Or, to center horizontally, remove fleqn class option and use gather* instead of align. Also you should be using align* and then there'd be no need for \nonumbers. Oct 13, 2016 at 12:07
  • @StevenB.Segletes I want the box to be centered across the line.
    – J. Barbosa
    Oct 13, 2016 at 12:25
  • @GuilhermeZ.Santos Thanks for the edit. But is there a way to supress the fleqn option just in this part of the code?
    – J. Barbosa
    Oct 13, 2016 at 12:28

1 Answer 1

2

To have unnumbered horizontal aligned equations remove the fleqn class option and use the gather* environment from amsmath without putting & alignment characters:

\documentclass[12pt]{article}
\usepackage{bm}
\usepackage{amsmath}
\usepackage[overload]{empheq}

\newcommand*\widebox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}
\newcommand*\rpos{\text{\textbf{r}}}

\begin{document}
    \begin{empheq}[box=\widebox]{gather*}
    \rpos = x \, \hat{i} + y \, \hat{j} + z \, \hat{k}, \\
    \mathbf R = (R_{\text{Terra}} + \text{h}) \: \hat{k}, \\
    \bm{\mathcal R} = \mathbf R + \rpos, \\
    \bm{\omega} = \omega (\sin\lambda \: \hat{i}+ \cos\lambda\:\hat{k}). % Last '\\' is not placed!
    \end{empheq}
\end{document}

Notice that this is not usual equation aligment as the equations won't be aligned at the = sign. To align through equal sign and have unnumbered equations use the align* environment!

Also notice the use of \sin and \cos for proper upright sine and cosine functions.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .