6

I want to

  • align 2 and 4 with the red lines on their right.
  • vertically enlarge the middle column to provide well balanced space for its contents.
  • vertically center the contents in the third column.

enter image description here

\documentclass[preview,varwidth,border=12pt]{standalone}
\usepackage[a5paper,margin=5mm]{geometry}
\usepackage{amsmath}
\usepackage{array}

\renewcommand{\arraystretch}{1.5} \begin{document} \begin{tabular}{|>{\centering}m{0.3\linewidth}|>{\centering}m{0.3\linewidth}|>{\centering}m{0.2\linewidth}|}\hline A pair of points & Slope & Type \tabularnewline\hline\hline $ \begin{array}{@{}c@{(}c@{}c@{,}c@{}c@{)}c@{}} A&&2&&-3&\ B&&-1&&4& \end{array}$ & $ \begin{aligned} m &= \frac{y_B-y_A}{x_B-x_A}\ &= \frac{4-(-3)}{-1-2}\ &= -\frac{7}{3} \end{aligned} $ & Decreasing \tabularnewline\hline \end{tabular} \end{document}

Note: My code above might be semantically wrong. Any modification is welcome.

Display Name
  • 46,933
  • 1
    I've taken the liberty of changing "$500" to "500 TeX.SE rep points", as I felt that the original announcement was, while eye-catching, also rather misleading. – Mico Oct 04 '20 at 15:52

7 Answers7

6

enter image description here

  1. No vertical rule, no double rules.
  2. No m type, one can use w{c}.
  3. Use a local macro in order to ease inputting the coordinates.
  4. Add some vertical space between the points.
  5. Increase the value of \jot in order to increase the distance between rows in aligned.
  6. Add some vertical space below the middle rule and above the bottom rule.
\documentclass{article}
\usepackage{amsmath}
\usepackage{array,booktabs}

\begin{document}

\begin{center} \begin{tabular}{ @{} w{c}{0.33333\columnwidth} @{} w{c}{0.33333\columnwidth} @{} w{c}{0.33333\columnwidth} @{} } \toprule A pair of points & Slope & Type \ \midrule \addlinespace $\setlength{\arraycolsep}{0pt} \newcommand{\point}[3]{#1&(&#2&,{}&#3&)} \begin{array}{ r r r l r r } \point{A}{2}{-3} \[2ex] \point{B}{-1}{4} \end{array}$ & $\addtolength{\jot}{6pt}\begin{aligned} m &= \frac{y_B-y_A}{x_B-x_A}\ &= \frac{4-(-3)}{-1-2}\ &= -\frac{7}{3} \end{aligned}$ & Decreasing \ \addlinespace \bottomrule \end{tabular} \end{center}

\end{document}

egreg
  • 1,121,712
3

A approach that uses stackengine in the left column, and eliminates the m columns to achieve vertical centering. Also \addstackgap was used to add vertical buffer above/below the middle column.

\documentclass[preview,varwidth,border=12pt]{standalone}
\usepackage[a5paper,margin=5mm]{geometry}
\usepackage{amsmath}
\usepackage{tabstackengine}
\TABstackMath
\setstackgap{L}{1.2\normalbaselineskip}
\renewcommand{\arraystretch}{1.5}
\begin{document}
\begingroup\tabcolsep=30pt
\begin{tabular}{|c|c|c|}\hline
A pair of points & Slope & Type \tabularnewline\hline\hline
\Matrixstack[r]{
A(&2,& -3)\\
B(&-1,& 4)
} & 
\addstackgap[5pt]{$
\begin{aligned}
m   &= \frac{y_B-y_A}{x_B-x_A}\\[4pt]
    &= \frac{4-(-3)}{-1-2}\\[4pt]
    &= -\frac{7}{3}
\end{aligned}$}
 & Decreasing \tabularnewline\hline
\end{tabular}\endgroup
\end{document}

enter image description here

2

Here's a way with cellspace, in the place of \arraystretch, and \multirow:

\documentclass[preview,varwidth,border=12pt]{standalone}
\usepackage[a5paper, margin=5mm]{geometry}
\usepackage{mathtools}
\usepackage{array}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}
\newcolumntype{M}[1]{S{m{#1}}}
\usepackage{multirow}

\begin{document}

\begin{tabular}{|wc{0.3\linewidth}| >{\centering}M{0.3\linewidth}|wc{0.2\linewidth}|}\hline A pair of points & Slope & Type \tabularnewline\hline\hline \multirow{3.9}{=}{\centering$\begin{matrix} A (\phantom{-}2,-3)\ B(-1,\phantom{-}4) \end{matrix}$} & $ \begin{aligned} m &= \frac{y_B-y_A}{x_B-x_A}\ &= \frac{4-(-3)}{-1-2}\ &= -\frac{7}{3} \end{aligned} $ & \multirow{4}{=}{\centering Decreasing} \tabularnewline\hline \end{tabular}

\end{document}

enter image description here

Bernard
  • 271,350
2

Here is a very basic proposal, mostly based on empheq and booktabs. It requires little tweaking to reach the expected result. The alignment of the left column contents is done using \hphantoms

% arara: lwpdflatex
\documentclass[preview,varwidth,border=12pt]{standalone}
\usepackage[a5paper,margin=5mm]{geometry}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{empheq}
\usepackage{booktabs}

\begin{document} \begin{tabular}{ccc}\toprule A pair of points & Slope & Type\\midrule \parbox{0.2\paperwidth}{ \begin{empheq}{align} A(\hphantom{-}2,-3)\ B(-1,\hphantom{-}4) \end{empheq} } & \parbox{0.2\paperwidth}{ \begin{empheq}{align} m &= \frac{y_B-y_A}{x_B-x_A}\ &= \frac{4-(-3)}{-1-2}\ &= -\frac{7}{3} \end{empheq} } & Decreasing\\bottomrule \end{tabular} \end{document}

enter image description here

BambOo
  • 8,801
  • 2
  • 20
  • 47
2

With cellspace and adjustbox:

\documentclass[preview,border=12pt]{standalone}
\usepackage[a5paper, margin=5mm]{geometry}
\usepackage{amsmath}
\usepackage{array}
\usepackage[column=O]{cellspace}
\newcolumntype{M}[1]{>{\centering}O{m{#1}}}
\usepackage{adjustbox}

\begin{document} { \setlength\arraycolsep{0pt} \setlength{\cellspacetoplimit}{4pt} \setlength{\cellspacebottomlimit}{4pt} \begin{tabular}{| c | Oc | c |} \hline \text{A pair of points} & \text{Slope} & Type \tabularnewline \hline\hline \adjustbox{valign=c,array=rrr} % <------- {% A( & 2, & -3)\ B( & -1, & 4)\ } & $\begin{aligned} m & = \frac{y_B-y_A}{x_B-x_A}\ & = \frac{4-(-3)}{-1-2}\ & = -\frac{7}{3} \end{aligned}$ & Decreasing \ \hline \end{tabular} } \end{document}

enter image description here

or with makecell, tabularx and adjustbox:

\documentclass[preview,border=12pt]{standalone}
\usepackage[a5paper, margin=5mm]{geometry}
\usepackage{amsmath}
\usepackage{makecell, tabularx}
    \newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{adjustbox}

\begin{document} \setlength\arraycolsep{0pt} \setcellgapes{3pt} \makegapedcells \begin{tabular}{| C | C | C |} \Xhline{1.2pt} \text{A pair of points} & \text{Slope} & Type \tabularnewline \Xhline{0.8pt} \adjustbox{valign=c,array=rrr} % <------- {% A( & 2, & -3)\ B( & -1, & 4)\ } & $\begin{aligned} m & = \frac{y_B-y_A}{x_B-x_A}\ & = \frac{4-(-3)}{-1-2}\ & = -\frac{7}{3} \end{aligned}$ & Decreasing \ \Xhline{1.2pt} \end{tabular} \end{document}

enter image description here or with booktabs and adjustbox:

\documentclass[preview,border=12pt]{standalone}
\usepackage[a5paper, margin=5mm]{geometry}
\usepackage{amsmath}
\usepackage{array, booktabs}
\usepackage{adjustbox}

\begin{document} { \setlength\arraycolsep{0pt} \begin{tabular}{ c c c } \toprule \text{A pair of points} & \text{Slope} & Type \tabularnewline \midrule \adjustbox{valign=c,array=rrr} % <------- {% A( & 2, & -3)\ B( & -1, & 4)\ } & $\begin{aligned} m & = \frac{y_B-y_A}{x_B-x_A}\ & = \frac{4-(-3)}{-1-2}\ & = -\frac{7}{3} \end{aligned}$ & Decreasing \ \bottomrule \end{tabular} } \end{document}

enter image description here

Zarko
  • 296,517
2

Some suggestions:

  • use a tabularx environment and a centered version of the X column type for all three columns

  • drop the instruction \renewcommand{\arraystretch}{1.5}

  • for column #1, set \setlength\arraycolsep{0pt} and use an array with three r-type columns; make sure to insert a bit of whitespace between "2," and "-3"

  • for column #2, keep using an aligned environment, but increase the value of jot

  • no need to do anything special for the contents of column #3

  • omit all vertical rules and use few, but well-spaced, horizontal rules with the help of the macros of the booktabs package

enter image description here

\documentclass[preview,varwidth,border=12pt]{standalone}
\usepackage[a5paper,margin=5mm]{geometry}
\usepackage{amsmath}

% new: \usepackage{tabularx,booktabs} \newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document} \noindent \begin{tabularx}{\textwidth}{@{} CCC @{}} \toprule A pair of points & Slope & Type \ \midrule \setlength\arraycolsep{0pt} $\begin{array}{rrr} A(& 2,&,-3) \ B(&-1,& 4) \end{array}$ & \addtolength\jot{4pt} $\begin{aligned} m &= \frac{y_B-y_A}{x_B-x_A} \ &= \frac{4-(-3)}{-1-2} \ &= -\frac{7}{3} \end{aligned}$ & Decreasing \ \bottomrule \end{tabularx} \end{document}

Mico
  • 506,678
0

An alternative solution with tblr environment of tabularray package:

\documentclass[preview,varwidth,border=12pt]{standalone}
\usepackage[a5paper,margin=5mm]{geometry}
\usepackage{amsmath}

\usepackage{tabularray} \UseTblrLibrary{booktabs}

\begin{document}

\begin{tblr}{Q[m,c,0.3\linewidth]Q[m,c,0.3\linewidth]Q[m,c,0.2\linewidth]} \toprule A pair of points & Slope & Type \ \midrule $\begin{tblr}{colsep=0pt, colspec={rrr}} A(& 2,,&-3) \ B(&-1,,& 4) \ \end{tblr}$ & $\begin{aligned} m &= \frac{y_B-y_A}{x_B-x_A}\ &= \frac{4-(-3)}{-1-2}\ &= -\frac{7}{3} \end{aligned} $ & Decreasing \ \bottomrule \end{tblr}

\end{document}

enter image description here

L.J.R.
  • 10,932