![如何创建一个在右列合并一些行的表格](https://linux22.com/image/275227/%E5%A6%82%E4%BD%95%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%E5%9C%A8%E5%8F%B3%E5%88%97%E5%90%88%E5%B9%B6%E4%B8%80%E4%BA%9B%E8%A1%8C%E7%9A%84%E8%A1%A8%E6%A0%BC.png)
我想创建一个像这样的表
第 4 列有 2 个单元格,在右侧垂直合并。
虽然使用在左侧合并它们很容易multirow
,但我不知道如何在右侧合并
这是我的源代码(使用IEEEtran.cls
):
\documentclass[conference]{IEEEtran}
% Add the compsoc option for Computer Society conferences.
% *** GRAPHICS RELATED PACKAGES ***
%
\ifCLASSINFOpdf
\usepackage[pdftex]{graphicx}
% declare the path(s) where your graphic files are
% \graphicspath{{../pdf/}{../jpeg/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.eps}
\else
% or other class option (dvipsone, dvipdf, if not using dvips). graphicx
% will default to the driver specified in the system graphics.cfg if no
% driver is specified.
\usepackage[dvips]{graphicx}
% declare the path(s) where your graphic files are
% \graphicspath{{../eps/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
\DeclareGraphicsExtensions{.eps}
\fi
% correct bad hyphenation here
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage{lscape}
\usepackage{multirow}
%\usepackage{subfig}
\usepackage{subfigure}
%\usepackage{subcaption}
\usepackage{tikz}
\def\checkmark{\tikz\fill[scale=0.4](0,.35) -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;}
\documentclass[conference]{IEEEtran}
\ifCLASSINFOpdf
\usepackage[pdftex]{graphicx}
\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.eps}
\else
\usepackage[dvips]{graphicx}
\DeclareGraphicsExtensions{.eps}
\fi
% correct bad hyphenation here
\hyphenation{op-tical net-works semi-conduc-tor}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{subfigure}
\begin{document}
\section{Introduction}
\section{xxx}
\begin{table}[h]
\centering
\begin{tabular}{ |p{0.6cm}|p{1cm}|p{0.6cm}|p{4cm}| }
\hline
{\fontsize{7}{60}\selectfont Source IP} & {\fontsize{7}{60}\selectfont Destination IP} & {\fontsize{7}{60}\selectfont CCN Name} & Example Application Scenarios \\
\hline
$\times$ & xx & xx& Content requester wants to hide its location/IP \\
\hline
dul & $\times$ & lus & \multirow{2}{*}{Content requester wants to hide its location/IP} \\
\cline{1-3}
ddd & $\times$ & lus & \\
\hline
$\times$ & Lucus & lus & Content requester wants to hide its location/IP \\
\hline
$\times$ & Lucus & lus & Content requester wants to hide its location/IP \\
\hline
\end{tabular}
\caption{xxxx}
\label{tab:header}
\end{table}
\begin{thebibliography}{1}
\end{thebibliography}
\end{document}
结果是两个单元格的宽度不相等。
答案1
@egreg 值得这份荣耀。以下是 MWE:
\begin{tabular}{l|l|l|l}
a1 & a2 & a3 & a4\\ \hline
b1 & b2 & b3 & \multirow{2}{*}{bc4}\\ \cline{1-3}
c1 & c2 & c3 & \\ \hline
d1 & d2 & d3 & d4
\end{tabular}
答案2
尝试以下代码:
\begin{table}[h]
\centering
\begin{tabular}{ |p{0.6cm}|p{1cm}|p{0.6cm}|p{4cm}| }
\hline
{\fontsize{7}{60}\selectfont Source IP} & {\fontsize{7}{60}\selectfont Destination IP} & {\fontsize{7}{60}\selectfont CCN Name} & Example Application Scenarios \\
\hline
$\times$ & v & v & Content requester wants to hide its location/IP \\
\hline
dul & $\times$ & lus & \multirow{2}{*}{\parbox[t]{4cm}{Content requester wants to hide its location/IP}} \\
\cline{1-3}
ddd & $\times$ & lus & \\
\hline
$\times$ & Lucus & lus & Content requester wants to hide its location/IP \\
\hline
$\times$ & Lucus & lus & Content requester wants to hide its location/IP \\
\hline
\end{tabular}
\caption{xxx }
\label{tab:header}
\end{table}