我尝试创建一个表格。但字母超出了列。请告诉我

我尝试创建一个表格。但字母超出了列。请告诉我

请有人帮助我创建这样的表格。它超出了列的范围。

这是我使用的代码:

\documentclass{article} 
\usepackage[english]{babel}

\begin{document}
\begin{center}
    \begin{tabular}{ | 4 | 4 | 4 | p{5cm} |}
    \hline
    Sr. no & Context in Use/Dataset & Techniques & Key Points
 +Pros and – Cons
 \\hline

    1 & For splice site recognisation in DNA Sequences  & Support vector
Machine(SVM)
 & +It performs better result for \nbegin identifying the Splice sites.
-It needs appropriate kernel function for training the data otherwise leads to poor classification.  
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells 
    across most of Scotland and Northern Ireland, 
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning. 
    Conditions will improve by early afternoon and continue 
    throughout the evening. \\
    \hline
    \end{tabular}
\end{center}

\end{document}

答案1

由于您没有在列声明中真正提到您的期望,因此我按如下方式编辑了您的代码。我还在第一行数据中的优点和缺点之间添加了换行符。

\documentclass{article}
\usepackage[english]{babel}

\begin{document}
\begin{center}
    \begin{tabular}{ | p{2cm} | p{2cm} | p{2cm} | p{6cm} |}
    \hline
    Sr. no & Context in Use/Dataset & Techniques & Key Points +Pros and – Cons \\ \hline
    1 & For splice site recognisation in DNA Sequences  & Support vector Machine(SVM) & +It performs better result for begin identifying the Splice sites.\newline -It needs appropriate kernel function for training the data otherwise leads to poor classification. However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells across most of Scotland and Northern Ireland, but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.  Conditions will improve by early afternoon and continue throughout the evening. \\
    \hline
    \end{tabular}
\end{center}

\end{document}

结果如下:

在此处输入图片描述

您的代码中的另一个错误是\\hline第一行数据后面的,这是不正确的,我用它替换了它\\ \hline

最后一个错误是\nbegin我删除了。

| p{2cm} | p{2cm} | p{2cm} | p{6cm} |还请注意,您可以通过替换来压缩列规范,*{3}{|p{2cm}} | p{6cm} |因为这里的前三列预计具有相同的描述。

我希望这能有所帮助。

答案2

您可以将tabularx环境设置为文本块的宽度,并为第 2、3 和 4 列启用自动换行。在下面的示例中,我使用修改后的列类型X来使用右边不规则排版,而不是对窄列中的材料进行完全对齐。

在此处输入图片描述

\documentclass{article} 
\usepackage[english]{babel}
\usepackage{tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{ | l | L | L | L |}
\hline
Sr.\ no & Context in Use\slash Dataset & Techniques 
        & Key Points, $+$~Pros and $-$~Cons\\
\hline

1 & For splice site recognition in DNA Sequences  
  & Support vector Machine (SVM)
  & $+$ It performs better result for identifying the Splice sites.\\
  & & & 
  $-$ It needs appropriate kernel function for training the data otherwise leads to poor classification. However, the strong breeze will bring down the temperatures. \\ 
\hline
Tue. & 9C & 19C 
     & Cloudy with rain, across many northern regions. Clear spells across most of Scotland and Northern Ireland, but rain reaching the far northwest. \\ 
\hline
Wed. & 10C & 21C 
     & Rain will still linger for the morning. Conditions will improve by early afternoon and continue throughout the evening. \\
\hline
\end{tabularx}

\end{document}

相关内容