2

I receive 20 error because of missing $ inserted. However. I put $ before and after each symbol.

Here is my code:

\documentclass[twocolumn]{article}
\usepackage{blindtext}
\begin{document}
\begin{table*}[htbp]
\centering
%\begin{threeparttable}
      \caption{Summary of a state-based EMS}
    \begin{tabular}{l|c|c|c}
        \hline

Battery SOC & State & Load Power & Fuel cell reference power \\ \hline
SOC \textgreater 80 \% & 1 & $P_{load}$ \le $P_{FCmin}$                 & $P_{FCmin}$   \\
                       & 2 & $P_{load}$ \le $P_{FCmin}$ + $P_{optdis}$  & $P_{FCmin}$  \\
                       & 3 & $P_{load}$ \le $P_{FCmax}$ + $P_{optdis}$  & $P_{FC}$ = $P_{load}$ - $P_{optdis}$ \\
                       & 4 & $P_{FCmax}$ + $P_{optdis}$ \textless $P_{load}$ & $P_{FCmax}$ \\ \hline
50\% \le $SOC$ \le 80\%  & 5 & $P_{load}$ \le $P_{FCmin}$                & $P_{FCmin}$ \\
                       & 6 & $P_{load}$ \le $P_{FCopt}$ - $P_{BATopt}$ & $P_{load}$ \\
                       & 7 & $P_{load}$ \le $P_{FCopt}$ + $P_{BATopt}$ & $P_{FCopt}$ \\
                       & 8 & $P_{load}$ \le $P_{FCmax}$                & $P_{load}$ \\
                       & 9 & $P_{load}$ \textgreater $P_{FCmax}$       & $P_{FCmax}$ \\ \hline
SOC \textless 50\%     & 10& $P_{load}$ \le $P_{FCmax}$ - $P_{optchar}$ & $P_{load}$ + $P_{optchar}$\\                                            & 11& $P_{load}$ \textgreater $P_{FCmax}$ - $P_{optchar}$ & $P_{FCmax}$ \\ \hline

      \end{tabular}
      \label{statebased}
%\end{threeparttable}
\end{table*}
\Blindtext\Blindtext
\end{document}
2
  • 1
    The problem here lies with your use of \le. However, I'd maintain the math part in your tabular a little better using some help from amsmath's \text.
    – Werner
    Aug 25, 2015 at 17:27
  • 2
    $P_{load}$ \le $P_{FCmin}$ should of course be $P_{load} \le P_{FCmin}$. Better, $P_{\mathrm{load}} \le P_{\mathrm{FCmin}}$. Your usage of \textgreater and \textless is similarly wrong: use a similar input as suggested with > and <
    – egreg
    Aug 25, 2015 at 17:28

3 Answers 3

2

You have consistently placed in the text mode symbols (commands) only to be used in mathmode. Corrected below

\documentclass[twocolumn]{article}
\usepackage{blindtext}
\begin{document}
\begin{table*}[htbp]
\centering
%\begin{threeparttable}
\caption{Summary of a state-based EMS}
\begin{tabular}{l|c|c|c}\hline
Battery SOC & State & Load Power & Fuel cell reference power \\ \hline
SOC \textgreater 80 \% & 1 & $P_{load} \le P_{FCmin}$& $P_{FCmin}$   \\ 
& 2 & $P_{load} \le P_{FCmin} + P_{optdis}$  & $P_{FCmin}$  \\ 
& 3 & $P_{load}\le P_{FCmax}+ P_{optdis}$& $P_{FC}$ = $P_{load} - P_{optdis}$ \\ 
& 4 & $P_{FCmax}$ + $P_{optdis}$ \textless $P_{load}$ & $P_{FCmax}$ \\ \hline
$50\% \le SOC \le 80\% $ & 5 & $P_{load} \le P_{FCmin}$ & $P_{FCmin}$ \\ 
& 6 & $P_{load} \le P_{FCopt} - P_{BATopt}$ & $P_{load}$ \\ 
& 7 & $P_{load} \le P_{FCopt} + P_{BATopt}$ & $P_{FCopt}$ \\ 
& 8 & $P_{load} \le P_{FCmax}$                & $P_{load}$ \\ 
& 9 & $P_{load}$ \textgreater $P_{FCmax}$       & $P_{FCmax}$ \\ \hline
SOC\textless 50\%&10& $P_{load}\le P_{FCmax}-P_{optchar}$ & $P_{load}+ P_{optchar}$\\                                        
& 11& $P_{load}$ \textgreater $P_{FCmax} - P_{optchar}$ & $P_{FCmax}$ \\ \hline
\end{tabular}
\label{statebased}
\end{table*}
\Blindtext\Blindtext
\end{document}

First Revision

In a case like this the use of standalone can assist in debugging.

\documentclass[border=12pt]{standalone}
\begin{document}
\begin{tabular}{l|c|c|c}\hline
Battery SOC&State & Load Power & Fuel cell reference power \\ \hline
$\mbox{SOC}>80\%$& 1    & $P_{load} \le P_{FCmin}$ & $P_{FCmin}$   \\ 
& 2 & $P_{load} \le P_{FCmin} + P_{optdis}$  & $P_{FCmin}$  \\ 
&3& $P_{load}\le P_{FCmax} + P_{optdis}$  & $P_{FC} = P_{load} - P_{optdis}$ \\ 
& 4 & $P_{FCmax} + P_{optdis}< P_{load}$ & $P_{FCmax}$ \\ \hline
$50\% \le \mbox{SOC}\le 80\%$&5& $P_{load} \le P_{FCmin}$ & $P_{FCmin}$ \\ 
& 6 & $P_{load} \le P_{FCopt} - P_{BATopt}$ & $P_{load}$ \\ 
& 7 & $P_{load} \le P_{FCopt} + P_{BATopt}$ & $P_{FCopt}$ \\ 
& 8 & $P_{load} \le P_{FCmax}$ & $P_{load}$ \\ 
& 9 & $P_{load}>P_{FCmax}$    & $P_{FCmax}$ \\ \hline
$\mbox{SOC} < 50\% $    & 10& $P_{load} \le P_{FCmax} - P_{optchar}$ & $P_{load} + P_{optchar}$\\                                         & 11& $P_{load} > P_{FCmax} - P_{optchar}$ & $P_{FCmax}$ \\ \hline
\end{tabular}
\end{document}

enter image description here

6
  • 2
    Why not also fixing the wrong usage of \textgreater and \textless?
    – egreg
    Aug 25, 2015 at 17:40
  • why@egreg '\textgreater' and '\textless' are wrong to be used ? Aug 25, 2015 at 17:48
  • @egreg Thanks for the reminder. On first pass I just fixed the math items. Then I had to look up the command \textless as I had never used that before. And if I did a second revision I would remove the vertical lines and consider aligning the math operators. (but I will leave that to the OP to do or ask in another question. ) Aug 25, 2015 at 17:50
  • 1
    @AmeenMohamedBassam - Use the macros \textless and \textgreater only in TeX's text mode. (Note the presence of the substring "text"...) For formulas, which should be typeset in TeX's math mode, use > and < in order to get the typographically correct amount of whitespace on either side of the symbol.
    – Mico
    Aug 25, 2015 at 17:54
  • is there a reason you've left the plus and "minus" out of the math scope? in the third line of the top right-hand block, there is a hyphen where there should be a minus. the correct minus symbol won't be generated outside of math mode. compare the results in the middle block of the bottom two lines. Aug 25, 2015 at 18:17
8

The other answers have already pointed out that you weren't using TeX's math mode for symbols such as \le ("less than or equal"). In addition to fixing these issues, and to replacing text-mode symbols such as \textless and \textgreater with their math-mode equivalents (< and >), you should also give consideration to

  • using an array environment instead of a tabular environment, as most of the table's contents are formulas -- this will save you from having to type lots and lots of $ symbols to enter and exit math mode;

  • typesetting the subscript material in upright (roman) font shape;

  • left-aligning rather than center-setting the material in columns 1, 3, and 4;

  • not using any vertical bars in the table, and replacing all instances of \hline with the rule-drawing macros of the booktabs package: \toprule, \midrule, and \bottomrule; this will make for a more "open" look and thus for a more readable table.

enter image description here

\documentclass[twocolumn]{article}
\usepackage{blindtext,booktabs,caption}
\let\tn\textnormal  % shortcut macro
\begin{document}

\begin{table*}
\centering
\caption{Summary of a state-based EMS} \label{statebased}

$\begin{array}{@{} lcll @{}}  % use "array" instead of "tabular"
\toprule
\tn{Battery SOC} & \tn{State} & \tn{Load Power} & \tn{Fuel cell reference power} \\ 
\midrule
\tn{SOC} > 80 \% 
& 1 & P_{\tn{load}} \le P_{\tn{FCmin}} & P_{\tn{FCmin}} \\ 
& 2 & P_{\tn{load}} \le P_{\tn{FCmin}} + P_{\tn{optdis}}  & P_{\tn{FCmin}}  \\ 
& 3 & P_{\tn{load}} \le P_{\tn{FCmax}} + P_{\tn{optdis}}  & P_{\tn{FC}} = P_{\tn{load}} - P_{\tn{optdis}} \\ 
& 4 & P_{\tn{load}} > P_{\tn{FCmax}} + P_{\tn{optdis}}  & P_{\tn{FCmax}} \\ 
\addlinespace
50\% \le \tn{SOC} \le 80\%  
& 5 & P_{\tn{load}} \le P_{\tn{FCmin}} & P_{\tn{FCmin}} \\ 
& 6 & P_{\tn{load}} \le P_{\tn{FCopt}} - P_{\tn{BATopt}} & P_{\tn{load}} \\ 
& 7 & P_{\tn{load}} \le P_{\tn{FCopt}} + P_{\tn{BATopt}} & P_{\tn{FCopt}} \\ 
& 8 & P_{\tn{load}} \le P_{\tn{FCmax}} & P_{\tn{load}} \\ 
& 9 & P_{\tn{load}} > P_{\tn{FCmax}}  & P_{\tn{FCmax}} \\ 
\addlinespace
\tn{SOC} < 50\%     
& 10& P_{\tn{load}} \le P_{\tn{FCmax}} - P_{\tn{optchar}} & P_{\tn{load}} + P_{\tn{optchar}}\\                                         & 11& P_{\tn{load}} > P_{\tn{FCmax}} - P_{\tn{optchar}} & P_{\tn{FCmax}} \\ 
\bottomrule
\end{array}$

\end{table*}
\Blindtext\Blindtext
\end{document}
3
  • 1
    @AmeenMohamedBassam This version of your table is by far the most professional in appearance. Note how the using both booktabs and the array environments produces both superior output and very readable source code. And the judicious use of \let reduced the amount of typing required. Aug 25, 2015 at 22:05
  • Is it better to use \textnormal instead of \mathrm for textual subscripts?
    – onewhaleid
    Aug 25, 2015 at 22:25
  • 1
    @onewhaleid - For the example at hand, it turns out that the two methods -- \mathrm and \textnormal -- produce the same results. If the subscript strings consisted of two (or more) words, you'd find that \mathrm ignores interword spaces, which is probably not desired in these cases. \textnormal will generate text in the "prevailing" or "normal" text font. Usually, this will be a serif font. If, however, the "normal" text font were sans-serif and if the math-italics font were a serif font, it might be preferable to use \mathrm for a better coherence of the math parts of the document.
    – Mico
    Aug 26, 2015 at 11:17
3

With helo of package array you can significantly simplify your table code:

\documentclass[twocolumn]{article}
\usepackage{blindtext}
\usepackage{array,amsmath}

\begin{document}
\begin{table*}[htbp]
\centering
%\begin{threeparttable}
      \caption{Summary of a state-based EMS}
    \begin{tabular}{l|c|>{$}c<{$}|>{$}c<{$}}
        \hline

Battery SOC 
    & State & \text{Load Power}     
                & \text{Fuel cell reference power} \\ \hline
SOC \textgreater 80 \%  
    & 1     & P_{load} \le P_{FCmin}    
                & P_{FCmin}                         \\
    & 2     & P_{load} \le P_{FCmin} + P_{optdis}  
                & P_{FCmin}                         \\
    & 3     & P_{load} \le P_{FCmax} + P_{optdis}  
                & P_{FC} = P_{load} - P_{optdis}    \\
    & 4     & P_{\mathrm{FCmax}} + P_{\mathrm{optdis}} < P_{\mathrm{load}} 
                & P_{FCmax}                         \\ \hline
      \end{tabular}
    \label{statebased}
%\end{threeparttable}
\end{table*}
\Blindtext\Blindtext
\end{document}

As you use S ...$ is wrong, you left out math operators .... With \begin{tabular}{l|c|>{$}c<{$}|>{$}c<{$}} I define, that contents in columns are math expressions.. Because their heads contain text, I wrote them into one cell multicolumn (see code).

Edit: In the last row I change indices to text style, as suggest @egreg in his comment, to see, how textual indices is usually written. Similarly, you (can) changes other textual indices in math expressions.

2
  • 2
    P_{\mathrm{load}} and similarly for the other textual subscripts.
    – egreg
    Aug 25, 2015 at 17:41
  • @egreg, of course, I didn't put attention to this ... removing surpluses $ take me to much time. I will correct this one row to show OP if maybe he liked this correct writing indices.
    – Zarko
    Aug 25, 2015 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .