3

Im trying to put some \times and \power in a table, but it isn't quite working.

\usepackage{mathtools}
\usepackage{amsmath}

\begin{tabular}{| p{3cm} | p{9cm} }
\hline
\bf hardware & \bf rekensom\\
\hline
6506E & 1 - (1 - 0.9999909)^2 = 0.99999999991 * 100% = 99.9999999917%\\
\hline
6509E & 1 - (1 - 0.9999885)^2 = 0.99999999986 * 100% = 99.9999999868%\\
\hline
\end {tabular}

I also tried this, but it didnt work either:

\hline
6506E &  $$ 1 - (1 - 0.9999909)\power2 = 0.99999999991 \times 100\% $$\\
\hline

The error it gives here is

Undefined control sequence

Benedikt Bauer
  • 6,590
  • 2
  • 34
  • 60

2 Answers2

7

This should work. Please avoid \bf in favor of \textbf{...}.

\documentclass{article}
\pagestyle{empty}% for cropping
\begin{document}
\begin{tabular}{| p{3cm} | p{9cm} }
\hline
\textbf{hardware} & \textbf{rekensom} \\
\hline
6506E & $1 - (1 - 0.9999909)^2 = 0.99999999991 * 100\% = 99.9999999917\%$ \\
\hline
6509E & $1 - (1 - 0.9999885)^2 = 0.99999999986 * 100\% = 99.9999999868\%$ \\
\hline
\end {tabular}
\end{document}

enter image description here


Here, have a slightly enhanced version:

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{amsmath,booktabs}
\begin{document}
\begin{tabular}{lp{0.7\linewidth}}
    \toprule
    Hardware & Rekensom \cr
    \midrule
    6506E &
    $\aligned
        1 - (1 - 0.9999909)^2 &= 0.99999999991 \cdot 100\,\% \\
        &= 99.9999999917\,\%
    \endaligned$ \cr
    6509E &
    $\aligned
        1 - (1 - 0.9999885)^2 &= 0.99999999986 \cdot 100\,\% \\
        &= 99.9999999868\,\%
    \endaligned$ \cr
    \bottomrule
\end {tabular}
\end{document}

enter image description here

Henri Menke
  • 109,596
3

Let's consider your title's topic with a little more challenging input with integrals. I find Andrew's \eqbreak in \begin{aligned} ... \end{aligned} in table as a more configurable option here. Your table goes well with Henri's example but if you get integrals and other challenging operators eqbreak is useful. Changes

  • no booktabs with vertical lines [Zarko]
  • Andrew's \eqbreak for challenging operators etc integrals
  • \bgroup\def\arraystretch{1.5} ... \egroup for more space in cells
  • Explicitly \begin{aligned}...\end{aligned} [Andrew2]

Your example with integrals

\documentclass[english]{article}
\pagestyle{empty}% for cropping
\usepackage{amsmath, amsfonts,rotating}
\usepackage{physics}
% http://tex.stackexchange.com/a/139450/13173
% http://tex.stackexchange.com/a/324197/13173
\newcommand{\eqbreak}[1][2]{\\&\hskip#1em}
\begin{document}
\bgroup
\def\arraystretch{1.5}%  1 is the default, change whatever you need
\begin{tabular}{| l | p{0.7\linewidth} |}
    \hline
    Hardware & Rekensom \\ \hline
    6506E &
    $\begin{aligned}
        1 - (1 - 0.9999909)^2 \eqbreak[-2] \times \int\limits_{-\infty}^{+\infty} A x \cdot \int\limits_{-\infty}^{+\infty} B y \times Z \alpha \, \text{dy} \, \text{dx} \\ &= 0.99999999991 \cdot 100\,\% \\
        &= 99.9999999917\,\%
    \end{aligned}$ \\ \hline
    6509E &
    $\begin{aligned}
        1 - (1 - 0.9999885)^2 &= 0.99999999986 \cdot 100\,\% \\
        &= 99.9999999868\,\%
    \end{aligned}$ \\ \hline
\end{tabular}
\egroup
\end{document}

Output

enter image description here

Limitations

  • no known
  • 1
    nice solution (+1), however, never mix booktabs rules with vertical lines: result is ugly. Also instead your interesting macro might to be better to use multline environment from asmamth/mathtool package (just my opinion). – Zarko Aug 10 '16 at 12:38
  • @Zarko Please, feel free to show us how you can do the thing with multiline and amsmath/mathtool. – Léo Léopold Hertz 준영 Aug 10 '16 at 12:50