我的 LaTeX 桌子太寬,不合適。我完全是一個使用 Overleaf 來編輯 LaTeX 學術計畫報告的初學者。我用來tablegenerator.com
產生和複製貼上的表格太寬,我不知道如何修復它。
這是代碼:
\begin{longtable}{|l|l|l|l|l|}
\caption{Tabular Summary of Literature Survey}
\label{tab:my-table}\\
\hline
S.No &
Paper Research Name \& Year &
Paper Publishing Details &
Summary &
Scope of Improvement \\ \hline
\endfirsthead
%
\endhead
%
1. &\begin{tabular}[c]{@{}l@{}}Stock Closing Price Prediction using \\ \\ Machine Learning Techniques\end{tabular} &
\begin{tabular}[c]{@{}l@{}}Published by: \\ Mehar Vij, \\ Deeksha Chandola,\\ Vinay Anand\\ Tikkiwal, \\ Arun Kumar\end{tabular} &
\begin{tabular}[c]{@{}l@{}}I. Due to the volatility\\ and non-linearity of \\ financial stock markets, \\ it is very difficult to \\ accurately predict stock \\ market returns.\\
\end{tabular} \\ \hline
\end{longtable}
我還有 7 行這樣的,我該怎麼辦?我已經做了其他所有事情,但在過去的 6 個小時裡我一直在做這件事,有人可以重寫這段程式碼,這樣我的桌子就不會太寬嗎?
我添加了它的外觀以及我想要它的外觀的圖像:
答案1
如果您要刪除表格內的所有這些幹擾表格環境,您可以用l
固定寬度的列替換您的列,例如p{3cm}
(您將調整寬度,以便它們與您擁有的任何頁面幾何形狀相符)
\documentclass{article}
\usepackage{geometry}
\usepackage{longtable}
\usepackage{array}
\begin{document}
\begin{longtable}{|p{0.92cm}|>{\raggedright}p{3cm}|>{\raggedright}p{3cm}|>{\raggedright}p{3cm}|>{\raggedright\arraybackslash}p{3cm}|}
\caption{Tabular Summary of Literature Survey}
\label{tab:my-table}\\
\hline
S.No &
Paper Research Name \& Year &
Paper Publishing Details &
Summary &
Scope of Improvement \\ \hline
\endfirsthead
%
\endhead
%
1. &Stock Closing Price Prediction using Machine Learning Techniques &
Published by: Mehar Vij, Deeksha Chandola, Vinay Anand Tikkiwal, Arun Kumar &
I. Due to the volatility and non-linearity of financial stock markets, it is very difficult to accurately predict stock market returns. & \\ \hline
\end{longtable}
\end{document}
或者你可以切換到tabularray
包:
\documentclass{article}
\usepackage{geometry}
\usepackage{tabularray}
\begin{document}
\begin{longtblr}[
caption={Tabular Summary of Literature Survey},
label={tab:my-table}
]{
colspec={lX[l]X[l]X[l]X[l]},
vlines,hlines
}
S.No &
Paper Research Name \& Year &
Paper Publishing Details &
Summary &
Scope of Improvement \\
1. &Stock Closing Price Prediction using Machine Learning Techniques &
Published by: Mehar Vij, Deeksha Chandola, Vinay Anand Tikkiwal, Arun Kumar &
I. Due to the volatility and non-linearity of financial stock markets, it is very difficult to accurately predict stock market returns. & \\
\end{longtblr}
\end{document}