我需要将图片和表格移到左侧,因为它们有一半在页面之外。我想知道您是否可以帮忙?我试过 \fbox,但它不起作用。
\begin{table}
\begin{tabular}{|c|c|c|c|}
\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
\multicolumn{2}{|c|}{\cellcolor{blue!10}MBE\%} & \multicolumn{2}{|c|}{\cellcolor{blue!10}C\textsubscript{v}(RMSE)}\\
\hline
Electricity Consumption & Gas Consumption & Electricity Consumption &Gas Consumption\\
\hline
4.1 & 2.25 & 14.27 & 7.81 \\
\hline
\end{tabular}
\caption{Calibration Results}\label{Results}
\end{table}
答案1
您的表格被截断,因为它比可用的文本宽度更宽。
尽管您可以将其相对于页面居中,同时让它均匀地突出到左右边距(例如使用包changepage
及其adjustwidth
环境),但如果您确保表格足够窄以适合可用空间,输出很可能看起来更好。 您可以通过在列标题中引入换行符来实现这一点,例如借助 \thead
包makecell
以下 MWE 显示了两种方法的比较:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{makecell} % provides the thead command
\renewcommand{\theadfont}{\normalsize}
\usepackage{changepage} % provides the adjustwidth environment
\usepackage{lipsum} % used for dummy text. Do not use in real document.
\begin{document}
\lipsum[4]
\begin{table}[htbp]
\centering
\begin{tabular}{|c|c|c|c|}
\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
\multicolumn{2}{|c|}{\cellcolor{blue!10}MBE\%} & \multicolumn{2}{|c|}{\cellcolor{blue!10}C\textsubscript{v}(RMSE)}\\
\hline
\thead{Electricity\\ Consumption} & \thead{Gas\\ Consumption} & \thead{Electricity\\ Consumption} & \thead{Gas\\ Consumption}\\
\hline
4.1 & 2.25 & 14.27 & 7.81 \\
\hline
\end{tabular}
\caption{Calibration Results}\label{Results}
\end{table}
\lipsum[4]
\begin{table}[htbp]
\begin{adjustwidth}{-1cm}{-1cm}
\centering
\begin{tabular}{|c|c|c|c|}
\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
\multicolumn{2}{|c|}{\cellcolor{blue!10}MBE\%} & \multicolumn{2}{|c|}{\cellcolor{blue!10}C\textsubscript{v}(RMSE)}\\
\hline
Electricity Consumption & Gas Consumption & Electricity Consumption &Gas Consumption\\
\hline
4.1 & 2.25 & 14.27 & 7.81 \\
\hline
\end{tabular}
\caption{Calibration Results}\label{Results}
\end{adjustwidth}
\end{table}
\lipsum[4]
\end{document}
答案2
无关 ...
- 您提供的代码片段与所显示的任何表格均无关
- 此片段也可以按以下方式(作为 MWE)写出:
\documentclass{article}
%\usepackage{geometry}
\usepackage{makecell, multirow}
\usepackage{siunitx}
\begin{document}
With use of \verb+\multicell+:
\begin {table}[ht]
\centering
\setcellgapes{3pt}
\makegapedcells
\caption {Acceptable Calibration Tolerances}
\label{mbe table}
\begin{tabular}{|c|c|c|}
\hline
Calibration Type
& Index
& Acceptable Value \\
\hline
Monthly & \makecell{MBE\textsubscript{month} \\
C\textsubscript{v}(RMSE\textsubscript{month})}
& \makecell{\SI{\pm 5}{\%} \\ \SI{15}{\%}} \\
\hline
Hourly & \makecell{MBE\textsubscript{month} \\
C\textsubscript{v}(RMSE\textsubscript{month})}
& \makecell{\SI{\pm 10}{\%} \\ \SI{30}{\%}} \\
\hline
\end{tabular}
\end {table}
With use of \verb+\multirow+:
\begin {table}[ht]
\centering
\setcellgapes{3pt}
\makegapedcells
\caption {Acceptable Calibration Tolerances}
\label{mbe table}
\begin{tabular}{|c|c|c|}
\hline
Calibration Type
& Index
& Acceptable Value \\
\hline
\multirow{2.4}{*}{Monthly}
& MBE\textsubscript{month}
& \SI{\pm 5}{\%} \\
& C\textsubscript{v}(RMSE\textsubscript{month})
& \SI{15}{\%} \\
\hline
\multirow{2.4}{*}{Hourly}
& MBE\textsubscript{month}
& \SI{\pm 10}{\%} \\
& C\textsubscript{v}(RMSE\textsubscript{month})
& \SI{30}{\%} \\
\hline
\end{tabular}
\end {table}
\end{document}
编辑:
提供新的代码片段后,看看其中的以下更改是否可以接受:
\begin{table}
\centering
\renewcommand\arraystretch{1.5}
\begin{tabular}{|c|c|c|c|}
\hline
\rowcolor{blue!10}
\multicolumn{2}{|c|}{Consumption MBE in \%}
& \multicolumn{2}{c|}{Consumption C\textsubscript{v}(RMSE)}\\
\hline
Electricity & Gas & Electricity & Gas \\
\hline
4.1 & 2.25 & 14.27 & 7.81 \\
\hline
\end{tabular}
\caption{Calibration Results}
\label{Results}
\end{table}
或者正如我在评论中提到的:
\begin{table}
\centering
\renewcommand\arraystretch{2}
\begin{tabular}{|c|c|c|c|}
\hline
\rowcolor{blue!10}
\multicolumn{2}{|c|}{MBE in \%}
& \multicolumn{2}{c|}{Consumption C\textsubscript{v}(RMSE)}\\
\hline
\makecell{Electricity\\Consumption}
& \makecell{Gas\\Consumption}
& \makecell{Electricity\\Consumption}
& \makecell{Gas\\Consumption} \\
\hline
4.1 & 2.25 & 14.27 & 7.81 \\
\hline
\end{tabular}
\caption{Calibration Results}
\label{Results}
\end{table}