10

This is my code:

\begin{tabular}{cccc}
$P(1)$ \\
$P(1)$ \\
$\forall n \in \N ((P(n) \land P(n+1) \implies P(n+2))$ \\
\hline
$\forall n \in \N (P(n))$ \\
\end{tabular} 

It looks like this:

Pic 1

I want it to look like this:

Pic 2

So my question really is, how can I align each line to the left within the tabular. Alternatively, is there a package just for this? Thanks in advance.

  • 2
    \begin{tabular}{l} where l implies "left aligned", whereas your code uses c meaning "centered". Also, your data employ only one column, so that {llll} is not needed, only {l}. – Steven B. Segletes Oct 3 '17 at 23:56
9

Alternatively, is there a package just for this?

Yes, I believe ebproof really fits the bill.

\documentclass{article}
\usepackage{ebproof}
\usepackage{mathtools}
\usepackage{amssymb}
\begin{document}
\begin{prooftree}
    \hypo{&P(1)}
    \infer[no rule]1{&P(2)}
    \infer[no rule]1{&\forall n \in \mathbf{N} ((P(n) \land P(n+1) \implies P(n+2))}
    \infer1{& \therefore \forall n \in \mathbf{N} (P(n))}
\end{prooftree}
\end{document}

The & character is here to tune the alignment, there is no need to explicitly declare the math. environment, and the package is flexible enough to accommodate multiple variations.

As a side note, you can get the therefore symbol using other techniques.

enter image description here

|improve this answer|||||
7

Since all material is in math mode, you should use an array environment, with a single column of type l, instead of a tabular environment.

enter image description here

\documentclass{article}
\usepackage{amssymb,booktabs}
\let\implies\Rightarrow % ? -- maybe '\rightarrow'?
\newcommand\N{\mathbb{N}}

\begin{document}
\noindent
$\begin{array}{@{}l@{}} % "@{}" suppresses whitespace padding
P(1) \\
P(2) \\
\forall n \in \N \bigl((P(n) \land P(n+1) \implies P(n+2)\bigr) \\
\midrule % for a well-spaced horizontal rule
\therefore\forall n \in \N (P(n)) 
\end{array}$
\end{document}
|improve this answer|||||
  • I have voted all your answers. Very good. +1 – Sebastiano Oct 4 '17 at 6:11
  • I always think that friendship is a sign of respect, kindness and good manners. When I can always vote for my friends and I think I have written it sometimes. – Sebastiano Oct 4 '17 at 6:37
  • @Sebastiano - Thanks, dear friend! :-) – Mico Oct 4 '17 at 7:19
7

Almost the same solution, but in display mode. I suggest using booktabs for horizontal rules, so you have a better vertical spacing:

\documentclass{article}
\usepackage{mathtools, amssymb}%
\usepackage{booktabs}
\newcommand\NN{\mathbf{N}}

\begin{document}

\[ \begin{array}{l}
  P(1) \\
  P(1) \\
  \forall n \in \NN,\bigl(P(n) \land P(n+1) \implies P(n+2)\bigr) \\
\midrule
  \therefore\forall n \in \NN (P(n))
\end{array} \]

\end{document} 

enter image description here

|improve this answer|||||
  • 2
    Your proof is wrong!!! ;-) – Clément Oct 4 '17 at 2:19
  • Does using a displaymath environment make a meaningful difference? The interior of the array environment will be in text-style either way, right? – Mico Oct 4 '17 at 4:35
  • @Mico: Of course it doesn't make a real difference. I only wanted to insist on the use of booktabs to improve the layout. As to the interior of arrays, that's true,; in general, I favour the use of medsize formulae, as defined by nccmath in this case, but there was no element in the O.P.'s code to illustrate this. – Bernard Oct 4 '17 at 8:25

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.