3

I have a table with three columns, in the second and third sometimes appear fractions:

\documentclass{scrartcl}
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}}
\begin{document}
\def\arraystretch{1.5}
\begin{tabular}{|c|C|C|C|c|}
\hline Ableitung des Vielfachen  & c f(x) & c f'(x) \\ 
\hline Quotientenregel & \frac{f(x) }{ g(x)} &  \frac{  f'(x) g(x)  -  f(x) g'(x) }{g(x)^2} \\ 
\hline
\end{tabular}
\end{document} 

How to make the parts of the fraction the same high as the parts above them without the fractions (doubling the rowheight when needed, also not shrinking the fontsize)?

2 Answers2

5

Use \dfrac from amsmath for this:

% arara: pdflatex

\documentclass{scrartcl}
\usepackage{mathtools} % loads amsmath
\usepackage{booktabs}
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}}

\begin{document}
    \begin{tabular}{lCC}\toprule
        Ableitung des Vielfachen  & c f(x) & c f'(x) \\\midrule
        Quotientenregel & \dfrac{f(x)}{g(x)} & \dfrac{  f'(x) g(x)  -  f(x) g'(x)}{g(x)^2} \\ % I corrected the math here...
        \bottomrule
    \end{tabular}
\end{document} 

enter image description here

LaRiFaRi
  • 43,807
  • Thank you! I didn't except it to be so easy ;) Can I ask for another small improvement please? I need the vertical lines in the table, but if I change \midrule to \hrule and add | in the tabular opening, the space between the fractions and the horizontal lines shrinks to much, any idea on how to solve this too? – user2567875 Jun 17 '15 at 07:37
  • @user2567875, booktabs and vertical lines doesn't work (well) together. From aesthetic point of view, vertical lines are not considered as good design ... – Zarko Jun 17 '15 at 07:41
  • 1
    @user2567875 - If you absolutely must have vertical rules (and hence can't use \toprule, \midrule, etc), take a look at the posting Inserting a small vertical space in a table and, in particular, the answer that uses typographic struts. – Mico Jun 17 '15 at 07:43
  • @user2567875 Bidde bidde. See Zarko's answer for the vertical rules. But I will not give a solution with such. As you can see, booktabs provides perfect spacing above and below the math-term. Just great. And the more lines, the less readable. I would even replace \midrule by \addlinespace but I have not seen the full table... – LaRiFaRi Jun 17 '15 at 08:12
  • @LaRiFaRi I know thats regarded as typograpy-hell, and I would agree in about 90% of the cases. But I need strong visual structure for my brain to be able to memorize it. And since I will write more annotations by hand into the printout later, the "grid" just has to be there to pre-set the structure I need. – user2567875 Jun 17 '15 at 08:51
1

If you persist on vertical rules, than (good old) mdwtab will give nice result: enter image description here

and code:

\documentclass{scrartcl}
\usepackage{mathtools} % loads amsmath
\usepackage{mdwtab}

\begin{document}
    \begin{tabular}{|l|Mc|Mc|}
\hlx{hv}
        Ableitung des Vielfachen  & c f(x) & c f'(x) \\
\hlx{vhvv}
        Quotientenregel & \dfrac{f(x)}{g(x)} & \dfrac{  f'(x) g(x)  -  f(x) g'(x)}{g(x)^2} \\ % I corrected the math here...
\hlx{vvh}
    \end{tabular}
\end{document}
Zarko
  • 296,517