\documentclass[journal]{IEEEtran}
\hyphenation{Smart Grid}
\usepackage[classicReIm]{kpfonts}
\usepackage{siunitx,booktabs}
\usepackage{subfloat}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{color} %for colors
\usepackage{epstopdf}
\usepackage{url}
\usepackage{hhline}%%%
\usepackage{float} %for fix the image position
%\usepackage[]{algorithm2e}
\usepackage{amsmath} %% for case bracket
%\usepackage{url}
\usepackage{multirow} % for devide row
\usepackage{caption}
%\usepackage{subcaption} % forr subfigures
\usepackage{multicol}
%\usepackage{subfig}
%\usepackage{cite}
\usepackage{cleveref}
\usepackage{amsmath}
\pagenumbering{gobble} %%% for without page numbers
\usepackage{float}
%\usepackage{algorithm}
\usepackage{array}
\usepackage{pdflscape}
\usepackage[classicReIm]{kpfonts}
\begin{document}
\begin{table}[H]
\centering \small
\tablesize{\footnotesize}
\caption{Comprehension of recent and relevant work.} \label{litrature}
\begin{tabular}{C{2.5cm}C{6cm}C{2.5cm}C{2.5cm}}
\toprule
\centering{\bf Methodologies } & \centering{\bf Features}&\centering{\bf Targets Achieved}&\bf{Limitations and Remarks} \\
\midrule
%\hline Optimal power scheduling method for DR in HEMS is presented in \cite{9} & GA & Cost and PAR reduction & Increased system complexity \\
MILP& Optimal domestic load scheduling \cite{35} & Electricity cost reduction & The cost is reduced at expense of user discomfort\\
\midrule Greedy algorithm& Heuristic optimization of generic cost model \cite{6} & Reduced user frustration and electricity cost & The PAR is ignored and complexity of the system is increased \\
\midrule GWO and ILP &GWO applied to economic load dispatch problems \cite{3}& Load dispatching in off-peak hours & Solved economic load dispatch (ELD) problems in the current study \\ \bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
您需要定义C
列。我的定义来自这里。
\documentclass[journal]{IEEEtran}
\usepackage{siunitx,booktabs}
\usepackage{float} %for fix the image position
\usepackage{amsmath} %% for case bracket
\pagenumbering{gobble} %%% for without page numbers
\usepackage{float}
\usepackage{array}
\usepackage[classicReIm]{kpfonts}
% from https://tex.stackexchange.com/a/175138/121799
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{table}[H]
\centering \small
\caption{Comprehension of recent and relevant work.} \label{litrature}
\begin{tabular}{C{2.5cm}C{6cm}C{2.5cm}C{2.5cm}}
\toprule
\textbf{Methodologies } & \textbf{Features}&\textbf{Targets Achieved}&\bf{Limitations and Remarks} \\
\midrule
%\hline Optimal power scheduling method for DR in HEMS is presented in \cite{9} & GA & Cost and PAR reduction & Increased system complexity \\
MILP& Optimal domestic load scheduling \cite{35} & Electricity cost reduction & The cost is reduced at expense of user discomfort\\
\midrule
Greedy algorithm& Heuristic optimization of generic cost model \cite{6} & Reduced user frustration and electricity cost & The PAR is ignored and complexity of the system is increased \\
\midrule
GWO and ILP &GWO applied to economic load dispatch problems \cite{3}& Load dispatching in off-peak hours & Solved economic load dispatch (ELD) problems in the current study \\ \bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
您显示的代码中存在很多问题。
- 您真的需要加载所有软件包吗?
- 你加载了几个包两次,不要这样做!
- 仔细查看调用包的顺序。在你的情况下,包
cleveref
应该最后调用。如果你想使用,请hyperref
加载它前cleveref
! - 对于您的表格的问题,使用的字体无关(我对其进行了评论)。
C
您在表格中使用的定义缺失。因为您加载了array
我认为\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
您正在使用的内容,但您没有将其复制到代码中。如果您使用p{#1}
而不是我的,m{#1}
请查看下面添加的屏幕截图以了解差异!- 我对您的表格做了一些漂亮的打印,以便读者可以更快地找到表格中的特殊单元格。
- 针对表格中的问题,我注释掉了代码中所有不需要的包。请检查加载包的不同顺序!
请注意,这
\centering
不适用于您在环境中使用的类table
。为了直观地展示这一点,我添加了包showframe
。它显示了打字区域和边距...原因是类IEEEtran
使用了两列布局。然后环境table
必须适合一列,但您使用的表超出了可能的范围\columnwidth
。要摆脱这种情况,请使用环境table*
。它跨越两列...我发表评论是
\tablesize{\footnotesize}
因为它引发了错误消息comand \tablesize undefined
。- 您使用的命令
\bf
已过时,您可以改用\textbf{...}
(如我在以下代码中所做的那样)。另一种方法是更改\bf
为\bfseries
。 - 因为您没有给我们
bib
文件,所以我只是在表格中评论了您对书籍等的引用(\cite
)...
使用以下代码
\documentclass[journal]{IEEEtran}
%usepackage[classicReIm]{kpfonts}
%\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{float} % for fix the image position
%\usepackage{subfloat}
\usepackage{caption}
%\usepackage{subcaption} % for subfigures
%\usepackage{graphicx}
%\usepackage{color} % for colors
%\usepackage{epstopdf}
%\usepackage{url}
%\usepackage{hhline}%%%
%\usepackage[]{algorithm2e}
%\usepackage{amsmath} % for case bracket
%\usepackage{multirow} % for devide row
%\usepackage{multicol}
%\usepackage{subfig}
%\usepackage{cite}
%\usepackage{algorithm}
\usepackage{array}
%\usepackage{pdflscape}
\usepackage{showframe}
%\usepackage{cleveref} % <===============================================
\hyphenation{Smart Grid}
\pagenumbering{gobble} %%% for without page numbers
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{table}[H]
% \centering
\small
%\tablesize{\footnotesize} % <==========================================
\caption{Comprehension of recent and relevant work.}
\label{litrature}
\begin{tabular}{C{2.5cm}C{6cm}C{2.5cm}C{2.5cm}} % C
\toprule
\textbf{Methodologies}
& \textbf{Features}
& \textbf{Targets Achieved}
& \textbf{Limitations and Remarks} \\
\midrule
%\hline Optimal power scheduling method for DR in HEMS is presented in \cite{9} & GA & Cost and PAR reduction & Increased system complexity \\
MILP
& Optimal domestic load scheduling %\cite{35}
& Electricity cost reduction
& The cost is reduced at expense of user discomfort\\
\midrule
Greedy algorithm
& Heuristic optimization of generic cost model %\cite{6}
& Reduced user frustration and electricity cost
& The PAR is ignored and complexity of the system is increased \\
\midrule
GWO and ILP
& GWO applied to economic load dispatch problems %\cite{3}
& Load dispatching in off-peak hours
& Solved economic load dispatch (ELD) problems in the current study \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
得到结果:
table
或者更好地显示文档中填充列的环境问题:
对表使用以下代码(我使用包blindtext
来生成虚拟文本来填充列)和环境table*
:
\blindtext
\begin{table*}
\centering % <========================================================
\small
%\tablesize{\footnotesize} % <==========================================
\caption{Comprehension of recent and relevant work.}
\label{tab:litraturea}
\begin{tabular}{C{2.5cm}C{6cm}C{2.5cm}C{2.5cm}} % C
\toprule
\textbf{Methodologies}
& \textbf{Features}
& \textbf{Targets Achieved}
& \textbf{Limitations and Remarks} \\
\midrule
%\hline Optimal power scheduling method for DR in HEMS is presented in \cite{9} & GA & Cost and PAR reduction & Increased system complexity \\
MILP
& Optimal domestic load scheduling %\cite{35}
& Electricity cost reduction
& The cost is reduced at expense of user discomfort\\
\midrule
Greedy algorithm
& Heuristic optimization of generic cost model %\cite{6}
& Reduced user frustration and electricity cost
& The PAR is ignored and complexity of the system is increased \\
\midrule
GWO and ILP
& GWO applied to economic load dispatch problems %\cite{3}
& Load dispatching in off-peak hours
& Solved economic load dispatch (ELD) problems in the current study \\
\bottomrule
\end{tabular}
\end{table*}
\Blindtext
您将获得以下结果:
完整的代码包含两个表(请参阅带有的表的更好的标签\label{tab:<name>}
):
\documentclass[journal]{IEEEtran}
%usepackage[classicReIm]{kpfonts}
%\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{float} % for fix the image position
%\usepackage{subfloat}
%\usepackage{caption} % unsupported in IEEEtran!
%\usepackage{subcaption} % for subfigures
%\usepackage{graphicx}
%\usepackage{color} % for colors
%\usepackage{epstopdf}
%\usepackage{url}
%\usepackage{hhline}%%%
%\usepackage[]{algorithm2e}
%\usepackage{amsmath} % for case bracket
%\usepackage{multirow} % for devide row
%\usepackage{multicol}
%\usepackage{subfig}
%\usepackage{cite}
%\usepackage{algorithm}
\usepackage{array}
%\usepackage{pdflscape}
\usepackage{showframe}
\usepackage{blindtext}
%\usepackage{cleveref} % <===============================================
\hyphenation{Smart Grid}
\pagenumbering{gobble} %%% for without page numbers
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{table}[H]
% \centering
\small
%\tablesize{\footnotesize} % <==========================================
\caption{Comprehension of recent and relevant work.}
\label{tab:litrature}
\begin{tabular}{C{2.5cm}C{6cm}C{2.5cm}C{2.5cm}} % C
\toprule
\bf Methodologies
& \bf Features
& \bf Targets Achieved
& \bf{Limitations and Remarks} \\
\midrule
\bfseries Methodologies
& \bfseries Features
& \bfseries Targets Achieved
& \bfseries{Limitations and Remarks} \\
\midrule
\textbf{Methodologies}
& \textbf{Features}
& \textbf{Targets Achieved}
& \textbf{Limitations and Remarks} \\
\midrule
%\hline Optimal power scheduling method for DR in HEMS is presented in \cite{9} & GA & Cost and PAR reduction & Increased system complexity \\
MILP
& Optimal domestic load scheduling %\cite{35}
& Electricity cost reduction
& The cost is reduced at expense of user discomfort\\
\midrule
Greedy algorithm
& Heuristic optimization of generic cost model %\cite{6}
& Reduced user frustration and electricity cost
& The PAR is ignored and complexity of the system is increased \\
\midrule
GWO and ILP
& GWO applied to economic load dispatch problems %\cite{3}
& Load dispatching in off-peak hours
& Solved economic load dispatch (ELD) problems in the current study \\
\bottomrule
\end{tabular}
\end{table}
\Blindtext
\blindtext
\begin{table*}
\centering % <========================================================
\small
%\tablesize{\footnotesize} % <==========================================
\caption{Comprehension of recent and relevant work.}
\label{tab:litraturea}
\begin{tabular}{C{2.5cm}C{6cm}C{2.5cm}C{2.5cm}} % C
\toprule
\textbf{Methodologies}
& \textbf{Features}
& \textbf{Targets Achieved}
& \textbf{Limitations and Remarks} \\
\midrule
%\hline Optimal power scheduling method for DR in HEMS is presented in \cite{9} & GA & Cost and PAR reduction & Increased system complexity \\
MILP
& Optimal domestic load scheduling %\cite{35}
& Electricity cost reduction
& The cost is reduced at expense of user discomfort\\
\midrule
Greedy algorithm
& Heuristic optimization of generic cost model %\cite{6}
& Reduced user frustration and electricity cost
& The PAR is ignored and complexity of the system is increased \\
\midrule
GWO and ILP
& GWO applied to economic load dispatch problems %\cite{3}
& Load dispatching in off-peak hours
& Solved economic load dispatch (ELD) problems in the current study \\
\bottomrule
\end{tabular}
\end{table*}
\Blindtext
\end{document}
答案3
您的代码存在一些严重问题。列C
类型未定义甚至不是最严重的问题。
文档
IEEEtran
类默认采用双列布局。您需要使用table*
环境而不是table
环境,以便表格内容可以安全地跨越两列。由于
table*
环境跨越两列,因此您不妨利用这一事实,使用tabularx
环境而不是环境。我建议您对左侧列tabular
使用基本列类型,对接下来的三列使用列类型。l
X
caption
已知和包subcaption
与文档类不兼容IEEEtran
。不要加载这些包。相反,只需依赖IEEEtran
文档类提供的标题格式化算法即可。尽量让表格材料看起来更开放,主要是通过使用更少的水平线。另外,不要过度使用大胆的。当然,对于手头的表格,使用大胆的因为标题单元格可能会显得俗气,甚至有点粗俗。
正如已经指出的那样这个答案,不要多次加载包。事实上,问问自己是否真的需要当前加载的所有包。下面的代码仅加载使表可编译所需的包。
\documentclass[journal]{IEEEtran}
\usepackage[classicReIm]{kpfonts}
\usepackage{booktabs,tabularx,lipsum}
\begin{document}
\begin{table*}
\caption{Summary of recent and relevant work.} \label{litrature}
\begin{tabularx}{\textwidth}{@{}lXXX@{}}
\toprule
Methodologies & Features & Targets Achieved & Limitations and Remarks \\
\midrule
%\hline Optimal power scheduling method for DR in HEMS is presented in \cite{9} & GA & Cost and PAR reduction & Increased system complexity \\
MILP& Optimal domestic load scheduling \cite{35} & Electricity cost reduction & The cost is reduced at expense of user discomfort\\
\addlinespace %\midrule
Greedy algorithm& Heuristic optimization of generic cost model \cite{6} & Reduced user frustration and electricity cost & The PAR is ignored and complexity of the system is increased \\
\addlinespace %\midrule
GWO and ILP &GWO applied to economic load dispatch problems \cite{3}& Load dispatching in off-peak hours & Solved economic load dispatch (ELD) problems in the current study \\
\bottomrule
\end{tabularx}
\end{table*}
\lipsum[1-30] % filler text
\end{document}