3

I would like to align all the "for all x > something" expressions in the following tabular environment.

enter image description here

My code for the above is as follows:

\begin{tabular}{rl|l}
    1. & $f(x) \le g(x + y) \quad \forall x > 1$ & $x$ blah blah $f(x)$ and blah\\
    2. & $g(x) \le g(x + y) + \log(x) \quad \forall x > 1$ & $\log(x)$ and $e^x$ blah blah\\
    3. & $x \le \frac{(2\log(y))}{\sin(x)} \quad \forall x > 10$ & Blah blah $\cos(x)$ and $y$\\
    4. & $f(x, y) = \left(e^{h(x)} + g(y)\right)^{e^x}$ & Using 3. and blah blah $x + y$\\
    \hline
    Hence & $x$ is $\mathcal{O}(x^x)$ & Because blah blah
\end{tabular}

I tried to perform the alignment using the aligned environment, but I have been unsuccessful. The following are my attempts:

Attempt 1

\begin{tabular}{rl|l}
    1. & $\begin{aligned}
           &f(x) \le g(x + y) &&\quad \forall x > 1\\
           &g(x) \le g(x + y) + \log(x) &&\quad \forall x > 1\\
           &x \le \frac{(2\log(y))}{\sin(x)} &&\quad \forall x > 10\\
           &f(x, y) = \left(e^{h(x)} + g(y)\right)^{e^x}
       \end{aligned}$ & $x$ blah blah $f(x)$ and blah\\
    2. & & $\log(x)$ and $e^x$ blah blah\\
    3. & & Blah blah $\cos(x)$ and $y$\\
    4. & & Using 3. and blah blah $x + y$\\
    \hline
    Hence & $x$ is $\mathcal{O}(x^x)$ & Because blah blah
\end{tabular}

Output: enter image description here

Attempt 2

\begin{tabular}{rl|l}
    $\begin{aligned}
        1. \\
        2. \\
        3. \\
        4.
    \end{aligned}$ &
    $\begin{aligned}
       &f(x) \le g(x + y) &&\quad \forall x > 1\\
       &g(x) \le g(x + y) + \log(x) &&\quad \forall x > 1\\
       &x \le \frac{(2\log(y))}{\sin(x)} &&\quad \forall x > 10\\
       &f(x, y) = \left(e^{h(x)} + g(y)\right)^{e^x}
    \end{aligned}$ &    
    $\begin{aligned}
        &\text{$x$ blah blah $f(x)$ and blah}\\
        &\text{$\log(x)$ and $e^x$ blah blah}\\
        &\text{Blah blah $\cos(x)$ and $y$}\\
        &\text{Using 3. and blah blah $x + y$}
    \end{aligned}$\\
    \hline
    Hence & $x$ is $\mathcal{O}(x^x)$ & Because blah blah
\end{tabular}

Output: enter image description here

In my second attempt, I managed to achieve the desired equation alignment, but the alignment across the rows of the table is still off.

1 Answer 1

3

Use \hphantom and zero-width box:

\documentclass{article}

\begin{document}

\begin{tabular}{rl|l}
  \gdef\tmpbox{$g(x)\leq g(x+y)+\log(x)$}%
  1. & \hbox to0pt {$f(x) \le g(x + y)$}\hphantom{\tmpbox}\quad $\forall x > 1$ & $x$ blah blah $f(x)$ and blah\\
  2. & $g(x) \le g(x + y) + \log(x) \quad \forall x > 1$ & $\log(x)$ and $e^x$ blah blah\\
  3. & \hbox to0pt{$x \le \frac{(2\log(y))}{\sin(x)}$}\hphantom{\tmpbox}\quad $\forall x > 10$ & Blah blah $\cos(x)$ and $y$\\
  4. & $f(x, y) = \left(e^{h(x)} + g(y)\right)^{e^x}$ & Using 3. and blah blah $x + y$\\
  \hline
  Hence & $x$ is $\mathcal{O}(x^x)$ & Because blah blah
\end{tabular}

\end{document}

enter image description here

You must log in to answer this question.

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