1

I have this as my current table which is fine, but I would like there to be vertical lines too just to make it look that bit neater. I'd also like horizontal lines between each row but this would require resizing the rows to avoid the fractions on the right column clashing with the line?

\begin{center}
\begin{tabular}{cc}
    \toprule
    \bfseries $f(t)$ & 
    \bfseries $\Lap[f(t)]$\\
    \midrule
    $k$ & $\frac ks$ \\ $e^{at}$ & $\frac{1}{s-a}$ \\ $\sin{(at)}$ & $\frac{a}{s^2+a^2}$ \\ $\cos{(at)}$ & $\frac{s}{s^2+a^2}$ \\ $t^n$ & $\frac{n!}{s^{n+1}}$ \\ $\sinh{(at)}$ & $\frac{a}{s^2-a^2}$ \\ $\cosh{(at)}$ & $\frac{s}{s^2-a^2}$ \\
    \bottomrule

\end{tabular}
\end{center}
David Carlisle
  • 757,742
DannyBland
  • 1,141
  • 1
    Do you mean somethin like \begin{tabular}{|c|c|}? – rtzll Feb 05 '13 at 14:21
  • 1
    Vertical rules doesn't work well with booktabs, see the manual or http://tex.stackexchange.com/questions/88929/vertical-table-lines-are-discontinuous-with-booktabs. With \midrules you won't get any clashing, by the way. – Torbjørn T. Feb 05 '13 at 14:23
  • @ChristianR. This won't really work acceptably with booktabs. The booktabs documentation has some very good arguments about why for most tables, vertical lines are not appropriate. See e.g. Vertical lines are discontinuous with booktabs. – Alan Munn Feb 05 '13 at 14:24
  • Exactly that for the vertical! Thank you. I also added a \midrule after every line and I'll try printing to see if the lines meet as the PDF suggests they don't. – DannyBland Feb 05 '13 at 14:26
  • @AlanMunn You are absolutely right, I overlooked the use of booktabs. – rtzll Feb 05 '13 at 14:31
  • 3
    There is no use loading booktabs if you want vertical lines, the package explicitly introduces constructs that are incompatible with vertical lines and documents that vertical lines are evil. So If you want vertical lines (which are not always evil:-) use the standard latex \hline for horizontal lines. – David Carlisle Feb 05 '13 at 14:34
  • There is a booktabs tag but I don't think the OP added it. If this is true, it's not clear if references to booktabs are relevant. @DannyBland Please turn your code into a minimal working example so we can see the context. –  Feb 05 '13 at 14:55
  • 1
    @MarcvanDongen The presence of \toprule, \midrule entails booktabs use. (But I agree that Danny should turn this into a compilable example.) – Alan Munn Feb 05 '13 at 15:02
  • @AlanMunn Thanks. I had overlooked \toprule and friends. –  Feb 05 '13 at 17:37

1 Answers1

2

When using a table containing only formulas it might be easier to use the array environment, which needs to be in math-mode (here displaymath). If you want to use verticle lines, you shouldn't use booktabs, simply use \hline instead.

The most of the following code is self-explanatory, but maybe not \renewcommand\arraystretch{1.5}, which is used to widen the rowheight, because otherwise the fractures will touch the lines.

Code

\documentclass{article}
\renewcommand\arraystretch{1.5}

\begin{document}
\begin{center}
\begin{displaymath}
\begin{array}{|c|c|}
\hline
\mathbf{f(t)} & \mathbf{\textbf{Lap}[f(t)]} \\ \hline \hline
k             & \frac ks           \\ \hline
e^{at}        & \frac{1}{s-a}      \\ \hline
\sin{(at)}    & \frac{a}{s^2+a^2}  \\ \hline
\cos{(at)}    & \frac{s}{s^2+a^2}  \\ \hline
t^n           & \frac{n!}{s^{n+1}} \\ \hline
\sinh{(at)}   & \frac{a}{s^2-a^2}  \\ \hline
\cosh{(at)}   & \frac{s}{s^2-a^2}  \\ \hline
\end{array}
\end{displaymath}
\end{center}
\end{document}

Result

image

rtzll
  • 5,531
  • This is very badly vertically positioned. It seems to me that \arraystretch isn't the right way to go here... – yo' Feb 05 '13 at 22:49