繁体   English   中英

如何在表Latex中添加垂直线

[英]How to Add vertical line in table Latex

我有这张乳胶代码。

\begin{table}[c]

\caption{\textbf{the results of analysis of variance (One Way ANOVA) 
  for the differences in the responses of the study sample according
  to different classes.}}
\bigskip
\centering

\begin{tabular}  {|M{4.5cm}|M{1.5cm}|M{1.5cm}|M{1.5cm}|M{1.75cm}|M{1.5cm}|M{2.5cm}|}
\hline
 \textbf{} & \textbf{Variance}         
 &\textbf{Sum of the squares }  & \textbf{Degrees of Freedom } &
 \textbf{Average Squares} &\textbf{P Value} &\textbf{Statistical  significance } \\ 
\hline

\multirow{3}{*}{\makecell{Q11.2}} & UK &122 & 0.14 & 0.348 &
\multirow{3}{*}{\makecell{0.978}  }  &  \multirow{3}{*}
{\makecell{0.329}}\\  \cline{2-5}
             & SA  & 224 & 0.10 & 0.304
             \\  \cline{2-5}
             & SA  & 224 & 0.10 & 0.304
             &&    \\ \hline

\end{tabular}
\end{table}

我得到了这个输出 在此输入图像描述

我不知道如何填补空的垂直线!

我的代码出了什么问题?

使用\\multirow ,必须在每行中包含希望多行跨越的空单元格。 这意味着该行

    & SA  & 224 & 0.10 & 0.304 \\

实际上应该读作

    & SA  & 224 & 0.10 & 0.304 & & \\

这应该会给你想要的结果!

另外两个评论:

  • 您可能想重新考虑\\makecell -command的用法,我认为这不是必需的。
  • 回答你的问题并不容易,因为你没有提供你可能使用的以下定义: \\newcolumntype{M}[1]{>{\\centering\\arraybackslash}m{#1}}

这是我使用的整个代码

\documentclass[a4paper,11pt]{article}
\usepackage[a4paper,text={160mm,255mm},centering,headsep=5mm,footskip=10mm]{geometry}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{array}
\usepackage{multirow}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
\begin{table}[c]

\caption{\textbf{the results of analysis of variance (One Way ANOVA) 
  for the differences in the responses of the study sample according
  to different classes.}}
\bigskip
\centering

\begin{tabular}{|M{4.5cm}|M{1.5cm}|M{1.5cm}|M{1.5cm}|M{1.75cm}|M{1.5cm}|M{2.5cm}|}
\hline
    & \textbf{Variance} & \textbf{Sum of the squares} & 
        \textbf{Degrees of Freedom } & \textbf{Average Squares} &
        \textbf{P Value} & \textbf{Statistical  significance } \\ 
\hline
  \multirow{3}{*}{Q11.2} & UK &122 & 0.14 & 0.348 & 
        \multirow{3}{*}{0.978} & \multirow{3}{*}{0.329}\\  
\cline{2-5}
             & SA  & 224 & 0.10 & 0.304 & & \\
\cline{2-5}
             & SA  & 224 & 0.10 & 0.304 & & \\ 
\hline
\end{tabular}
\end{table}
\end{document}

生成此输出 在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM