为什么我的日期在表格列中没有对齐并且浮动?

为什么我的日期在表格列中没有对齐并且浮动?

我已将此表格添加到我的文档中,并且某些单元格中的数据浮动在任何地方,例如第 9 行“优势”和第 14 行“劣势”。

此图是输出结果的一半

    \begin{longtable}{|p{0,6cm}|p{7cm}|p{7cm}|}
        \caption{\it{SWOT Analysis}}
        \label{tab:data_table}\\ \hline
        \textbf{Ref} &  \textbf{Strengths} & \textbf{Weaknesses}  \\
        \hline
        \endfirsthead
        \multicolumn{3}{l}%
        {\tablename\ \thetable\ -- \textit{Continues...}} \\
        \hline
        \textbf{Ref} &  \textbf{Strengths} & \textbf{Weaknesses}  \\
        \hline
        \endhead
        \endfoot
        \hline
        \endlastfoot
    
    \hline
    1   & \begin{tabular}[c]{@{}l@{}}Classification of Urdu sentences  \\on Document-level,  \\Lexicon bases sentiment analysis\end{tabular}                         & \begin{tabular}[c]{@{}l@{}}No method to tackle implicit negation  \\Noun phrases need to be considered\end{tabular}                                          \\ 
    \hline
    3   & \begin{tabular}[c]{@{}l@{}}Utilized Long Short-term memory\\ (LSTM) for polarity detection in  \\Roman Urdu\end{tabular}                                     & \begin{tabular}[c]{@{}l@{}}No validation of data collection process,\\ no data preprocessing method declared\\ Methods are not transparent \\~\end{tabular}  \\ 
    \hline
    5   & \begin{tabular}[c]{@{}l@{}}806 Roman Urdu sentences collection, \\features Construction and application\\ on different multilingual classifiers\end{tabular} & \begin{tabular}[c]{@{}l@{}}Limited dataset \\No structure of the dataset\end{tabular}                                                                        \\ 
    \hline
    6   & Lexicon and Rule-based
      methods used to construct a RU classification algorithm, ML and phonetic
      techniques used                                        & \begin{tabular}[c]{@{}l@{}}Limited categorization of the dataset \\No normalizing of the dataset\end{tabular}                                                \\ 
    \hline
    7   & 15,000 roman Urdu
      sentences collected                                                                                                                    & The dataset
      contained biographies and not general                                                                                                          \\ 
    \hline
    8   & \begin{tabular}[c]{@{}l@{}}22,000 sentences of RU were collected, \\Supervised \& unsupervised methods used\end{tabular}                                & Ambiguous
      combination of classifiers                                                                                                                       \\ 
    \hline
    9   & 1200 text documents
      of Urdu news were collected, performed a linguistic analysis                                                                         & \begin{tabular}[c]{@{}l@{}}No character-level features used \\Needs evaluation on state-of-the-art\\ semantic techniques\end{tabular}                          \\ 
    \hline
    11  & Existing
      values collated to different techniques                                                                                                         & \begin{tabular}[c]{@{}l@{}}No dataset mentioned \\No classification methods mentioned\end{tabular}                                                           \\ 
    \hline
    12  & A massive
      dataset of 5 lac sentiments, Use of lexical classifying techniques                                                                             & \begin{tabular}[c]{@{}l@{}}Confusing representation of the dataset \\Lack of credible results\end{tabular}                                                   \\ 
    \hline
    14  & \begin{tabular}[c]{@{}l@{}}1000 reviews collected and Various \\frameworks compared\\ i.e., Hadoop Mapreduce\end{tabular}                                    & Limited
      dataset Classifiers were not general and were overfitting on the given
      dataset                                                                   \\
    \hline
    \end{longtable}

答案1

首先,您可以加载pdflscape包并使用其landscape环境,这实质上会旋转内容并使表格适合页面。

您还可以添加一些额外的空间。作为第一个调整,我会重新定义 \arraystretch为高于1.0以增加行间距。

由于列已定义为p{},单元格变为常规段落。因此,您可以使用\par\newline强制换行,并且tabular不再需要 s。此外,\setstretch{<factor>}fromsetspace包还可以更改每个段落中各行之间的间距

在此处输入图片描述

通过删除垂直线并添加预定义规则,可以实现不同的布局,在我看来更好booktabs

希望能帮助到你

在此处输入图片描述

在此处输入图片描述

第一个截图的代码

\documentclass{article}
\usepackage{setspace}
\usepackage{array}
\usepackage{longtable}    % Allows selecting all possible font size
\usepackage{pdflscape}

\newcommand\locstrut{\rule[-9pt]{0pt}{21pt}}
\renewcommand{\arraystretch}{1.5}

\begin{document}

\begin{landscape}
    \setstretch{1.17}
    \begin{longtable}{|p{0,6cm}|p{7cm}|p{7cm}|}
        \caption{\it{SWOT Analysis}}
        \label{tab:data_table} \\
        \hline
        \locstrut \textbf{Ref} &  \textbf{Strengths} & \textbf{Weaknesses}  \\
        \endfirsthead
        \multicolumn{3}{l}{\tablename\ \thetable\ -- \textit{Continues...}} \\
        \hline
        \locstrut \textbf{Ref} &  \textbf{Strengths} & \textbf{Weaknesses} \\
        \hline \endhead
        \hline \endlastfoot
    
        \hline
        1 &
        Classification of Urdu sentences\par
            on Document-level,\par
            Lexicon bases sentiment analysis &
            No method to tackle implicit negation\par
            Noun phrases need to be considered\\ 
        \hline
        3 &
        Utilized Long Short-term memory\par
            (LSTM) for polarity detection in\par
            Roman Urdu &
            No validation of data collection process,\par
            no data preprocessing method declared\par
            Methods are not transparent \\
        \hline
        5 &
        806 Roman Urdu sentences collection,\par
            features Construction and application\par
            on different multilingual classifiers &
            Limited dataset\par
            No structure of the dataset \\ 
        \hline
        6 &
        Lexicon and Rule-based methods used to construct a RU classification algorithm, ML and phonetic techniques used &
            Limited categorization of the dataset\par
            No normalizing of the dataset \\ 
        \hline
        7 &
        15,000 roman Urdu sentences collected &
        The dataset contained biographies and not general \\ 
        \hline
        8 &
        22,000 sentences of RU were collected,\par
            Supervised \& unsupervised methods used &
        Ambiguous combination of classifiers \\
        \hline
        9 &
        1200 text documents of Urdu news were collected, performed a linguistic analysis &
        No character-level features used\par
            Needs evaluation on state-of-the-art\par
            semantic techniques \\
        \hline
        11 &
        Existing values collated to different techniques &
        No dataset mentioned\par
            No classification methods mentioned \\ 
        \hline
        12 &
        A massive dataset of 5 lac sentiments, Use of lexical classifying techniques & 
        Confusing representation of the dataset\par
            Lack of credible results \\
        \hline
        14 &
        1000 reviews collected and Various\par
            frameworks compared\par
            i.e., Hadoop Mapreduce &
        Limited dataset Classifiers were not general and were overfitting on the given dataset \\
    \end{longtable}
\end{landscape}

\end{document}

第二张截图的代码

\documentclass{article}
\usepackage{setspace}
\usepackage{array}
\usepackage{longtable}    % Allows selecting all possible font size
\usepackage{booktabs}
\usepackage{pdflscape}
\usepackage[table]{xcolor}

\newcommand\locstrut{\rule[-9pt]{0pt}{21pt}}
\renewcommand{\arraystretch}{1.65}

\begin{document}

\begin{landscape}
    \setstretch{1.05}
    \begin{longtable}{p{0,6cm}p{7cm}p{7cm}}
        \caption{\it{SWOT Analysis}} \label{tab:data_table}\\
        \toprule
        \locstrut \textbf{Ref} &  \textbf{Strengths} & \textbf{Weaknesses}  \\
        \midrule
        \endfirsthead

        \multicolumn{3}{l}{\tablename\ \thetable\ -- \textit{Continues...}} \\
        \toprule
        \locstrut \textbf{Ref} &  \textbf{Strengths} & \textbf{Weaknesses} \\
        \midrule
        \endhead

        \midrule \endfoot
        \bottomrule \endlastfoot
    
        1 &
        Classification of Urdu sentences\newline
            on Document-level,\newline
            Lexicon bases sentiment analysis &
            No method to tackle implicit negation\newline
            Noun phrases need to be considered\\ 
        %\hline
        3 &
        Utilized Long Short-term memory\newline
            (LSTM) for polarity detection in\newline
            Roman Urdu &
            No validation of data collection process,\newline
            no data preprocessing method declared\newline
            Methods are not transparent \\
        %\hline
        5 &
        806 Roman Urdu sentences collection,\newline
            features Construction and application\newline
            on different multilingual classifiers &
            Limited dataset\newline
            No structure of the dataset \\ 
        %\hline
        6 &
        Lexicon and Rule-based methods used to construct a RU classification algorithm, ML and phonetic techniques used &
            Limited categorization of the dataset\newline
            No normalizing of the dataset \\ 
        %\hline
        7 &
        15,000 roman Urdu sentences collected &
        The dataset contained biographies and not general \\ 
        %\hline
        8 &
        22,000 sentences of RU were collected,\newline
            Supervised \& unsupervised methods used &
        Ambiguous combination of classifiers \\
        %\hline
        9 &
        1200 text documents of Urdu news were collected, performed a linguistic analysis &
        No character-level features used\newline
            Needs evaluation on state-of-the-art\newline
            semantic techniques \\
        %\hline
        11 &
        Existing values collated to different techniques &
        No dataset mentioned\newline
            No classification methods mentioned \\ 
        %\hline
        12 &
        A massive dataset of 5 lac sentiments, Use of lexical classifying techniques & 
        Confusing representation of the dataset\newline
            Lack of credible results \\
        %\hline
        14 &
        1000 reviews collected and Various\newline
            frameworks compared\newline
            i.e., Hadoop Mapreduce &
        Limited dataset Classifiers were not general and were overfitting on the given dataset \\
    \end{longtable}
\end{landscape}

\end{document}

答案2

  • 对于您的表格,遗漏了一些重要的信息,因为使用了documentclass页面布局,并且如果您真的需要长表格(从代码片段来看,这并不明显。
  • 还不清楚为什么你将表格嵌套在单元格中
  • 我猜,下面的表格设计应该接近你想要的:

[![在此处输入图片描述][1]][1]

对于此表,我使用包longtblr中定义的,tabularray因为在您的文档中您使用了longtable。但是,如上所示,此代码片段可以放在一页上。

\documentclass{article}
\usepackage{geometry}
\usepackage[english]{babel}
\hyphenation{do-cu-me-nt}
\usepackage{microtype}
\usepackage{tabularray}

\begin{document}
    \begin{longtblr}[
caption = {SWOT Analysis},
  label = {tab:data_table}
                    ]{hlines, vlines,
                     colspec = {c *{2}{X[j]}},
                      colsep = 3pt,
                      row{1} = {font=\small\bfseries},
                     rowhead = 1
                     }
Ref.&  Strengths
        &   Weaknesses                              \\
1   &   Classification of Urdu sentences on Document- level, 
        Lexicon bases sentiment analysis 
        &   No method to tackle implicit negation 
            Noun phrases need to be considered      \\
3   &   Utilized Long Short-term memory 
            (LSTM) for polarity detection in 
            Roman Urdu 
        &   No validation of data collection process, 
            no data preprocessing method declared 
            Methods are not transparent \\
5   &   806 Roman Urdu sentences collection, 
        features Construction and application 
        on different multilingual classifiers 
            &   Limited dataset 
                No structure of the dataset \\
6   &   Lexicon and Rule-based methods used to construct a RU classification algorithm, 
        ML and phonetic techniques used  
        &   Limited categorization of the dataset 
            No normalizing of the dataset \\
7   &   15,000 roman Urdu sentences collected 
        &   The dataset contained biographies and not general \\
8   &   22,000 sentences of RU were collected, 
        Supervised \& unsupervised methods used 
        &   Ambiguous combination of classifiers \\
9   &   1200 text documents of Urdu news were collected, performed a linguistic analysis 
        &   No character-level features used 
            Needs evaluation on state-of-the-art 
            semantic techniques \\
11  &   Existing values collated to different techniques 
        &   No dataset mentioned 
            No classification methods mentioned \\
12  &   A massive dataset of 5 lac sentiments, Use of lexical classifying techniques 
        &   Confusing representation of the dataset\par
            Lack of credible results \\
14  &   1000 reviews collected and Various 
        frameworks compared i.e., Hadoop Mapreduce 
        &   Limited dataset Classifiers were not general and 
            were overfitting on the given dataset \\
    \end{longtblr}
\end{document}




  [1]: https://i.stack.imgur.com/Slihe.png

相关内容