\documentclass{article}
\usepackage[a4paper,left=3cm,right=3cm,top=2cm,bottom=2cm]{geometry} % to fit both tables
\usepackage{caption}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{booktabs} % for the second example
\begin{document}
\begin{table}[htp]
\centering % used for centering table
\caption{GENERAL PARAMETERS FOR THE SIMULATION} % title of Table
\label{table:nonlin} % is used to refer this table in the text
\begin{tabular}{ | M{4cm} | M{4cm} | M{5cm} |} % centered columns (3 columns)
\hline\hline %inserts double horizontal lines
Parameter & Value & Observations and related works \\ % inserts table heading
\hline % inserts single horizontal line
Sa & 500m x 500m & Ar \\
\hline
\hline
\end{tabular}
\end{table}
\begin{table}[htp]
\centering % used for centering table
\caption{GENERAL PARAMETERS FOR THE SIMULATION} % title of Table
%\label{table:nonlin} % is used to refer this table in the text
\begin{tabular}{ M{4cm} M{4cm} M{5cm} } % centered columns (3 columns)
\toprule
Parameter & Value & Observations and related works \\ % inserts table heading
\midrule
Simulation a & 500m x 500m & Area \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
您需要\centering
在以下栏目中做:
\documentclass{article}
\usepackage[a4paper,left=3cm,right=3cm,top=2cm,bottom=2cm]{geometry} % to fit both tables
\usepackage{caption}
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{booktabs} % for the second example
\begin{document}
\begin{table}[htp]
\centering % used for centering table
\caption{GENERAL PARAMETERS FOR THE SIMULATION} % title of Table
\label{table:nonlin} % is used to refer this table in the text
\begin{tabular}{ | M{4cm} | M{4cm} | M{5cm} |} % centered columns (3 columns)
\hline\hline %inserts double horizontal lines
Parameter & Value & Observations and related works \\ % inserts table heading
\hline % inserts single horizontal line
Sa & 500m x 500m & Ar \\
\hline
\hline
\end{tabular}
\end{table}
\begin{table}[htp]
\centering % used for centering table
\caption{GENERAL PARAMETERS FOR THE SIMULATION} % title of Table
%\label{table:nonlin} % is used to refer this table in the text
\begin{tabular}{ M{4cm} M{4cm} M{5cm} } % centered columns (3 columns)
\toprule
Parameter & Value & Observations and related works \\ % inserts table heading
\midrule
Simulation a & 500m x 500m & Area \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
我添加了第二种排版表格的方法,这是我推荐的。
答案2
在这一行中:
\begin{tabular}{ | m{4cm} | m{4cm} | m{5cm} |} % centered columns (4 columns)
您需要将“居中对齐文本”参数添加到表格规范中。(http://en.wikibooks.org/wiki/LaTeX/Tables)
尝试以下方法:
\begin{tabular}{ | c m{4cm} | c m{4cm} | c m{5cm} |} % centered columns (4 columns)
如果这不起作用(我的机器上没有 LaTeX),请尝试删除参数m{4cm}
,看看是否能得到你想要的结果。如果在删除参数后需要重新调整表格大小m{4cm}
,请尝试执行这。