3

trying to achieve a structured, boxed equation, which is aligned at the "=". I googled for quite a time, maybe I used the wrong keywords bur I only found equations that are centred, or only one lined, but never aligned to "=". May best solution until now is this:

\documentclass[12pt]{book}
\setlength\parindent{0pt}
\usepackage{amsmath,mathtools}
\usepackage{empheq}
\setlength\fboxsep{0.5cm}
\begin{document}

\begin{center}
\begin{empheq}[box=\fbox]{align*}
  log_{b} a \overset{!}{=} \frac{lg(a)}{lg(b)} \\
  \\
  10^x=2 \\
  x=lg(2) \\
  10^{lg(2)}=2 \\
  \\
  a^n=c \\
  10^{lg(a)}^{n}=10^{lg(c)} \\
  10^{lg(a) /cdot n}=10^{lg(c)} \\
  lg(a)/cdot n=lg(c) \\
\end{empheq}
\end{center}
\end{document}

Sadly it doesn't display the \cdot AND it gives me a double superscript error because of the "^" AND I don't know how to define that it should align all lines to the "=", like in Microsoft Word f.e.

:/

Please, if someone would be so kind to deliver a short solution for this? :) Thx

3
  • You have put /cdot instead of \cdot. Commented May 2, 2020 at 12:39
  • 1
    Welcome to tex.sx. Commented May 2, 2020 at 14:36
  • My humble suggestion. Or you use amsmath, or mathtools. No togheter.
    – Sebastiano
    Commented May 2, 2020 at 19:33

3 Answers 3

3

You don't need empheq for this. In any case, there is no need for center around empheq; it's actually wrong to add it.

If you want to align the equals sign, tell TeX to with &.

\documentclass[12pt]{book}
\usepackage{amsmath}

\setlength\fboxsep{0.5cm}

\begin{document}

\[
\boxed{\begin{aligned}
  \log_{b} a &\overset{!}{=} \frac{\lg(a)}{\lg(b)} \\
  \\
  10^x&=2 \\
  x&=\lg(2) \\
  10^{\lg(2)}&=2 \\
  \\
  a^n&=c \\
  10^{\lg(a^{n})}&=10^{\lg(c)} \\
  10^{\lg(a) \cdot n}&=10^{\lg(c)} \\
  \lg(a)\cdot n&=\lg(c)
\end{aligned}}
\]

\end{document}

enter image description here

Note \log and \lg; also \cdot and not /cdot. I fixed the mathematical error in line 6.

Using “lg” for the base 10 logarithm is not common. In computer science it usually denotes the base 2 logarithm.

2
  • You should write \lg instead of lg
  • For a double superscript, we should write {a^b}^c
  • For the alignment, you have to put & before the =

Here is the code:

\documentclass[12pt]{book}
\setlength\parindent{0pt}
\usepackage{amsmath,mathtools}
\usepackage{empheq}
\setlength\fboxsep{0.5cm}

\begin{document}

\begin{center}
\begin{empheq}[box=\fbox]{align*}
  \log_{b} a & \overset{!}{=} \frac{\lg(a)}{\lg(b)} \\[1em]
  10^x& =2 \\
  x& =\lg(2) \\
  10^{\lg(2)}& =2 \\[1em]
  a^n& =c \\
  {10^{\lg(a)}}^{n} & =10^{\lg(c)} \\
  10^{\lg(a) \cdot n} & =10^{\lg(c)} \\
  \lg(a)\cdot n & =\lg(c) 
\end{empheq}
\end{center}
\end{document}

result of the above code

1
  • Wow thank you kindly. Very good. I am new to all this and at the start sometimes it is a bit overwhelming all at once.... Commented May 2, 2020 at 12:53
2

I guess lg denotes the \log function, and cdot, \cdots. The aligned environments (there are several) do not guess where you want to align, and you have to mark the alignment point with an ampersand. If you don't, they're by default aligned at the end of lines.

Unrelated remarks: you don't have to use the center environment for these equations, as they are centred. It only adds spurious vertical spacing to the normal spacing of equations. Also, if you load empheq, needless to load amsmath nor mathtools, as the former package already does it.

\documentclass[12pt]{book}
\setlength\parindent{0pt}
\usepackage{empheq}
\setlength\fboxsep{0.5cm}

\begin{document}

\begin{empheq}[box=\fbox]{align*}
  \log_{b} a & \overset{!}{=} \frac{\log(a)}{\log(b)} \\
  \\
  10^x & =2 \\
  x & =\log(2) \\
  10^{\log(2)} & =2 \\
  \\
  a^n & =c \\
 { 10^{\log(a)}}^{n} & =10^{\log(c)} \\
  10^{\log(a) /\cdot n} & =10^{\log(c)} \\
  \log(a)/\cdot n & =\log(c)
\end{empheq}

\end{document} 

enter image description here

1
  • Thank you kindly! Also appreciate the "Unrelated remarks". didn't know that, really usefull! Commented May 2, 2020 at 12:55

You must log in to answer this question.

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