簡體   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