如何启用 LaTeX 中的自动换行功能并强制文本换行?

如何启用 LaTeX 中的自动换行功能并强制文本换行?

我已经创建了一个表格,并固定了它的宽度,但问题是,当我写一段长文本时,文本会换行,我想在文本应该遵守行宽的情况下添加自动换行符。我该怎么做?我使用了 springer 模板。这是我的表格:

\documentclass{article}

\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}

\begin{document}



        \begin{table*}[htp]
        \scriptsize     
        
        %\begin{tabular}{|p{0.1\textwidth}|l|l|l|l|l|l|l|l|}
        
        
        \begin{tabular} {|p{0.1\textwidth}|p{0.1\textwidth}|p{0.1\textwidth}|p{0.1\textwidth}|p{0.1\textwidth}|p{0.1\textwidth}|p{0.1\textwidth}|p{0.1\textwidth}|p{0.01\textwidth}|} 
        \hline
        \begin{tabular}[c]{@{}l@{}}
        Type of ANN\end{tabular} 
        
        &
        
        \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x \end{tabular} 
        &
        \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x \end{tabular} 
        
        & Topology & 
        
        Input & Output & Objective & Dataset & Ref \\ \hline
        {\multirow{2}{*}{\rotatebox [origin=c]{90}{x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x }}}  & { \multirow{3}{*}{\rotatebox [origin=c]{90}{ Regression }}} & \begin{tabular}[l]{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x \end{tabular} & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & 
        
        \begin{tabular}{@{}l@{}}
        \tabitem x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\\
        \tabitem x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  .\\
        \tabitem x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .
        \\
        
        
        \end{tabular}
        
        
         & 
        
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\\
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  \\   
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  \\ %\hspace{0.28cm}
         rate.
        \\
        
        
          & \begin{tabular}{@{}l@{}}  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & r1 \\ \cline{3-9} 
         &  & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x \end{tabular} & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & 
         
         
         
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  \\
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  \\
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  \\
        
        
          & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x   model.\end{tabular} & r2 \\ \cline{1-1} \cline{3-9} 
        {\rotatebox [origin=c]{90}{ Feedback }}  &  & x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & 
        
         \begin{tabular} {@{}l@{}}
        Number of  users  connected in $t_{n}$.
        \\
        \end{tabular}
        
         & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  $t_{n+1}$.\end{tabular} & \begin{tabular}{@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & \multicolumn{1}{c|}{//} & r3 \\ \hline
        {\rotatebox [origin=c]{90}{   x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x    }} & {\rotatebox [origin=c]{90}{ Classification }} & x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  & \begin{tabular}{@{}l@{}}One hidden  layer.\end{tabular} & 
        
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x  . \\
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x . \\ 
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x . \\
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x . \\
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x . \\
         x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x . \\
        
         & \begin{tabular} {@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x .\end{tabular} & \begin{tabular} {@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x \end{tabular} & \begin{tabular} {@{}l@{}}x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x \end{tabular} & r4 \\ \hline
        
        \end{tabular}
        
        \end{table*}


\end{document}

答案1

很难知道所需的布局,因为发布的代码产生了太多错误而无法产生任何输出,并且您没有提供所需布局的图像。

但也许这可以让你开始,我删除了所有阻止换行的内部表格(因为它们强制l列),并调整了外部表格以适合您的 7 个主要列标题。所有列都允许换行,但实际上你需要根据实际含义调整宽度。

\documentclass{article}

\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}


\begin{document}



\begin{table*}[htp]
\scriptsize     
\setlength\tabcolsep{3pt}
\setlength\extrarowheight{2pt}
        
\begin{tabular} {@{}|
p{0.15\textwidth}|
p{0.15\textwidth}|
p{0.15\textwidth}|
p{0.1\textwidth}|
p{0.1\textwidth}|
p{0.1\textwidth}|
p{0.1\textwidth}|
@{}} 
        \hline

        Type of ANN
        
         & Topology & 
        
        Input & Output & Objective & Dataset & Ref \\ \hline


x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x & 
x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x & 
x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x &
x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x & 
x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x & 
x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x x x x x x x x x x x x x x x x x x x & 
x x x x x x x x x x x x x x x x x x x x x x x x x x x x  x x x x x x x x x x  \\
        


zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz  zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz & 
zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz  zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz & 
zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz  zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz &
zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz  zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz & 
zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz  zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz & 
zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz  zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz & 
zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz zz  zz zz zz zz zz zz zz zz zz zz  \\
\hline        
\end{tabular}
        
\end{table*}


\end{document}

在此处输入图片描述

相关内容