[英]LaTex table over the width of the page
我正在嘗試在 Latex 中復制此表。
但是我的表總是這樣出來的:
我的代碼:
\begin{center}
\begin{tabular}{c|c}
\textbf{SQL} & \textbf{MONGODB} \\
Database & Database \\
Table & Collection \\
Row & Document \\
Column & Field \\
& \\
\hline
& \\
\hline
& \\
\hline
& \\
\hline
& \\
\hline
& \\
\hline
& \\
\hline
& \\
\hline
& \\
\hline
\end{tabular}
\end{center}
您添加的圖像包含 6 個不同的表格。 在下面的 MWE 中,我復制了(近似)第 1 個表。 您可以使用相同的方法重現所有表格。
X
類型列需要包tabularx
。 您可以閱讀此 Wikibook 部分以獲取更多信息。booktabs
包用於更好的水平線。 在包文檔中,您將找到有關正式表的更多信息。caption
提供了在浮動環境中放置標題的更多控制。geometry
包可用於更改頁面尺寸。MWE:
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{geometry}
\begin{document}
\begin{table}
\centering
\caption{Terminologies in SQL and ...}
\label{tab:my_label}
\begin{tabularx}{\textwidth}{XX}
\toprule
\textbf{SQL} & \textbf{MONGODB} \\
\midrule
Database & Database \\
Table & Collection \\
Row & Document \\
Column & Field \\
Primary key (specify any unique column or column combination as primary key) & Primary key (the primary key is automatically set to the \_id field in MongoDB)\\
blah blah & blah blah \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
我的建議的草圖:
\documentclass{article}
\usepackage{lipsum}
\usepackage{tabularx,booktabs}
\begin{document}
\lipsum[4]
\begin{table}[!ht]
\sffamily
\caption{Terminologies in SQL \& corresponding in MongoDB}
\label{tab:my_label}
\centering
\begin{tabularx}{\textwidth}{*{2}{p{0.5\textwidth}}}
\toprule
\textbf{SQL} & \textbf{MongoDB}\\
\midrule
Database & Database\\
\dots & \dots \\
Primary key (specify any unique column or column combinations as primary key) & Primary key (the primary key is\par auto\-matically set to the \_id field\par in MongoDB)\\
\dots & \dots \\
\bottomrule
\end{tabularx}
\end{table}
\lipsum[4]
\end{document}
我添加了命令\\sffamily
以在 sans-serif-font 中輸出單個表。
命令\\par
是在類型為p
(段落)的列中手動添加換行符。
您可以更改表格的參數,例如使用:P、m 等來指定表格的寬度。 或者使用比較新的表格宏包(tabularray),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.