0

I'd like to have the third column (minus the header of that column) as a single cell. I was trying to use multirow and a "p" column to achieve the desired effect, but with no success. How might I do this?

Here is what I have so far:

\documentclass{article}
\usepackage{lscape}
\usepackage{longtable}
\begin{document}
\begin{landscape}
    {\renewcommand{\arraystretch}{1.5}
    \begin{longtable}{|p{3in}|p{4in}|p{1in}|}
        \hline
        \textbf{Conversion} & \textbf{Formulas} & \textbf{Restrictions} \\ \hline
        Cylindrical to rectangular: $(r,\theta,z) \to (x,y,z)$ \par Rectangular to cylindrical: $(x,y,z) \to (r,\theta,z)$ & $x = r \cos(\theta)$, $y=r \sin(\theta)$, $z=z$ \par $r=\sqrt{x^2+y^2}$, $\tan(\theta) = y/x$, $z=z$ & {} \\ \hline
        Spherical to cylindrical: $(\rho,\theta,\phi) \to (r,\theta,z)$ \par
        Cylindrical to spherical: $(r,\theta,z) \to(\rho,\theta,\phi) $ & $r= \rho \sin(\phi)$, $\theta = \theta$, $z = \rho \cos(\phi)$ \par $\rho = \sqrt{r^2+z^2}$, $\theta = \theta$, $\tan(\phi)=r/z$ & $r \ge 0$, $\rho \ge 0$ \par $0 \le \theta \le 2 \pi$ \par $0 \le \phi \le \pi$ \\ \hline
            Spherical to rectangular: $(\rho,\theta,\phi) \to (x,y,z)$ \par Rectangular to spherical: $(x,y,z) \to (\rho,\theta,\phi)$ & $x=\rho \sin(\phi) \cos(\theta)$, $y=\rho \sin(\phi) \sin(\theta)$, $z= \rho \cos(\phi)$ \par $\rho = \sqrt{x^2+y^2+z^2}$, $\tan(\theta) = y/x$, $\cos(\phi) = z/\sqrt{x^2+y^2+z^2}$ & {} \\ \hline
    \end{longtable}
    }
\end{landscape}
\end{document}
  • what do you mean by "a single cell" you can not have a cell for an entire longtable (well you can but then it won't break over a page, so why use longtable rather than a standard tabular?) also note center does nothing to longtable. – David Carlisle Nov 13 '14 at 17:39
  • In column 3, I'd like rows 2-4, to be merged since those restrictions are to be considered true for all the conversions listed. Hopefully that helps. – DJJerome Nov 13 '14 at 17:42
  • you could just use \cline instead of \hline for those two rules, or use multirow package (if you know there is no page break in the spanned rows) – David Carlisle Nov 13 '14 at 17:45
  • I tried using multirow but couldn't get it to work, hence my question. – DJJerome Nov 13 '14 at 17:48
1

enter image description here

\documentclass{article}
\usepackage[pdftex]{lscape}
\usepackage{array,longtable}
\begin{document}
\begin{landscape}
    \renewcommand{\arraystretch}{1.5}
    \begin{longtable}{|p{3in}|p{4in}|l|}
        \hline
        \textbf{Conversion} & \textbf{Formulas} & \textbf{Restrictions} \\ \hline
        Cylindrical to rectangular: $(r,\theta,z) \to (x,y,z)$ \par Rectangular to cylindrical: $(x,y,z) \to (r,\theta,z)$ & $x = r \cos(\theta)$, $y=r \sin(\theta)$, $z=z$ \par $r=\sqrt{x^2+y^2}$, $\tan(\theta) = y/x$, $z=z$ & {} \\
\cline{1-2}
        Spherical to cylindrical: $(\rho,\theta,\phi) \to (r,\theta,z)$ \par
        Cylindrical to spherical: $(r,\theta,z) \to(\rho,\theta,\phi) $ & $r= \rho \sin(\phi)$, $\theta = \theta$, $z = \rho \cos(\phi)$ \par $\rho = \sqrt{r^2+z^2}$, $\theta = \theta$, $\tan(\phi)=r/z$ & 
\smash{\begin{tabular}{@{}l@{}}
r \ge 0$, $\rho \ge 0$\\
 $0 \le \theta \le 2 \pi$ \\
 $0 \le \phi \le \pi$
\end{tabular}}
 \\ 
\cline{1-2}
            Spherical to rectangular: $(\rho,\theta,\phi) \to (x,y,z)$ \par Rectangular to spherical: $(x,y,z) \to (\rho,\theta,\phi)$ & $x=\rho \sin(\phi) \cos(\theta)$, $y=\rho \sin(\phi) \sin(\theta)$, $z= \rho \cos(\phi)$ \par $\rho = \sqrt{x^2+y^2+z^2}$, $\tan(\theta) = y/x$, $\cos(\phi) = z/\sqrt{x^2+y^2+z^2}$ & {} \\ \hline
    \end{longtable}
\end{landscape}
\end{document}
1

The code will be simpler with the makecell package, as it allows for line breaks inside cells, so that you don't have to specify colum widths:

\documentclass[a4paper]{article}
\usepackage{lscape}
\usepackage{longtable, multirow}
\usepackage{makecell}
\renewcommand\cellalign{lc}
\usepackage[math]{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\begin{document}

\begin{landscape}
\begin{longtable}{|Sl|Sl| Sl|}%
    \hline
    \textbf{Conversion} & \textbf{Formulas} & \textbf{Restrictions} \\
    \hline
    \makecell{Cylindrical to rectangular: $ (r,θ,z) \to (x,y,z) $ \\[0.7ex] Rectangular to cylindrical: $ (x,y,z) \to (r,θ,z) $} & \makecell{$ x = r \cos(θ) $, $ y = r \sin(θ) $, $ z = z $ \\[0.7ex] $ r = √{x^2+y^2}$, $ \tan(θ) = y/x $, $ z = z $} & \multirowcell{6}[-1.4ex]{ $r ≥ 0$, $ρ ≥ 0$ \\ $0 ≤ θ ≤ 2 \pi$ \\ $0 ≤ ϕ ≤ \pi$} \\
    \cline{1-2}
    \makecell{Spherical to cylindrical: $ (ρ,θ,ϕ) \to (r, θ, z) $ \\[0.7ex]
    Cylindrical to spherical: $ (r, θ, z) \to (ρ, θ, ϕ) $}
    & \makecell{$ r= ρ \sin(ϕ) $, $ θ = θ $, $z = ρ \cos(ϕ) $ \\[0.7ex]$ ρ = √{r^2+z^2}$, $ θ = θ $, $ \tan(ϕ)=r/z $} & \\
    \cline{1-2}
        \makecell{Spherical to rectangular: $(ρ, θ, ϕ) \to (x, y, z)$ \\[0.7ex] Rectangular to spherical: $(x, y, z) \to (ρ, θ, ϕ)$ }& \makecell{$x = ρ \sin(ϕ) \cos(θ) $, $ y = ρ \sin(ϕ) \sin(θ) $, $ z= ρ \cos(ϕ) $ \\[0.7ex] $ ρ = √{x^2+y^2+z^2} $, $ \tan(θ) = y/x $, $ \cos(ϕ) = z/√{x^2+y^2+z^2} $ } &\\
        \hline
\end{longtable}
\end{landscape}

\end{document} 

enter image description here

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.