长表中有多行和段落

长表中有多行和段落

我想将第三列(减去该列的标题)设置为单个单元格。我尝试使用多行和“p”列来实现所需效果,但没有成功。我该怎么做?

以下是我目前所掌握的信息:

\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}

答案1

在此处输入图片描述

\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}

答案2

使用该包后代码会更简单makecell,因为它允许在单元格内换行,这样您就不必指定列宽:

\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} 

在此处输入图片描述

相关内容