LaTeX gives error undefined control sequence table
You have a lot of issues in your shown code.
- Do you really need all the packages you are loading?
- You load several packages twice, do not do this!
- Have a closer look at the order of calling packages. In your case package
cleveref
should be called last. If you want to usehyperref
too load it beforecleveref
! - For the problem with your table the used font is not relevant (I commented it).
- The definition for
C
you used in your table is missing. Because you loadarray
I think\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
is what you are using but you had not copied into your code. If you usep{#1}
instead of mym{#1}
please check the added screenshot below for differences! - I did a little bit pretty printing with your table so the reader can faster locate a special cell in the table.
- I commented all not needed packages you used in your code for the issue with the table. Please check the different order of loading packages!
Please see that
\centering
is not working with your used class inside environmenttable
. To visualize this I added packageshowframe
. It shows typing area and margins ... The reason is that classIEEEtran
uses a two-column-layout. Then environmenttable
has to fit into one column, but your used table exceeds the possible\columnwidth
. To get rid of this use environmenttable*
instead. It spans both columns ...I commented
\tablesize{\footnotesize}
because it throws the error messagecomand \tablesize undefined
.- Your used command
\bf
is outdated, in your case you can use\textbf{...}
instead (as I did in the following code). An alternative would be to change\bf
to\bfseries
. - Because you gave us no
bib
file I simply commented your citing of books etc. in the table (\cite
) ...
With the following code
\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}
you get the result:
or better for showing the issue with environment table
with filled columns in document:
With using the following code for the table (I used package blindtext
to generate dummy text to fill the columns) with environment 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
you get the following result:
The complete code is with both tables (see the better label for the tables with \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}
Your code has some serious issues. The fact that the C
column type isn't defined is not even the most serious issue.
The
IEEEtran
document class employs a two-column layout by default. You need to employ atable*
environment instead of atable
environment, so that the tabular material may safely span both columns.Since the
table*
environment spans both columns, you might as well make use of this fact and employ atabularx
environment instead of atabular
environment. I suggest you use the basicl
column type for the left-hand column and theX
column type for the next three columns.The
caption
andsubcaption
packages are known not be compatible with theIEEEtran
document class. Don't load these packages. Instead, just rely on the caption formatting algorithms provided by theIEEEtran
document class.Do give the tabular material a more open "look", mainly by using fewer horizontal rules. Also, don't over-use bold-facing. For sure, for the table at hand, using bold-facing for the header cells risks coming across as tacky, maybe even a bit vulgar.
As already pointed out in this answer, don't load packages multiple times. In fact, do ask yourself if you really need all the packages you currently load. The code below loads only those packages that are required to make the table compilable.
\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}
You need to define the C
column. I took the definition from here.
\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}