6

Is it due to my eyes that these words W1 aren't of the same size here? Also I tried left aligned for the second column but somehow it looks skew to me. Please tell me if you have any idea to make it look nicer.

\documentclass[journal]{IEEEtran}
\usepackage{amsmath,amsfonts}
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\usepackage{booktabs}


\begin{document}

  \begin{table}[!h]
  \centering
  \caption{TEST FUNCTIONS}
  \label{tab:table1}
  \begin{tabular}{c l}
                            \toprule
STTC & FUL\\ \midrule
H1 & $W_1$ \\\midrule
H2  & $\frac{1}{W_1}$ \\\midrule
H3  & $\frac{1}{1-W_1}$  \\\midrule
H4  & $1-W_1$ \\\midrule
H5  & $\frac{W_1-1}{W_1}$ \\\midrule
H6  & $\frac{W_1}{W_1-1}$\\\bottomrule

\end{tabular}
\end{table} 

\end{document}

enter image description here

5
  • 7
    The font size in text style math fractions are of course smaller than the normal font size
    – daleif
    May 31, 2022 at 6:30
  • But all formulas in the second column is formated in math style with $ symbols. Is it normal to look different sizes like that? How can I make them of the same size?
    – hana
    May 31, 2022 at 6:32
  • 1
    $... $ is always text style math (unless under certain circumstances)
    – daleif
    May 31, 2022 at 6:34
  • That is what I meant. All the formulas in the second column are put inside text style math so should they have the same size?
    – hana
    May 31, 2022 at 6:37
  • 8
    @hana This is unrelated to tables. You are using inline textstyle math designed to fit in a normal height line. fractions use a smaller font just as superscripts do. Would you ask the same about $2+x^{2}$ where the second 2 is smaller? 2+½ is the same, the second 2 is smaller. You can use \dfrac instead of\frac to get display fractions. May 31, 2022 at 7:02

3 Answers 3

13

This is unrelated to tables. You are using inline textstyle math designed to fit in a normal height line. fractions use a smaller font just as superscripts do. The W is smaller just as the second 2 is smaller in 2+½ . You can use \dfrac instead of\frac to get display fractions.

enter image description here

\documentclass[journal]{IEEEtran}
\usepackage{amsmath,amsfonts}
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\usepackage{booktabs}


\begin{document}

  \begin{table}[!h]
  \centering
  \caption{TEST FUNCTIONS}
  \label{tab:table1}
  \begin{tabular}{c l}
                            \toprule
STTC & FUL\\ \midrule
H1 & $W_1$ \\\midrule
H2  & $\dfrac{1}{W_1}$ \\\midrule
H3  & $\dfrac{1}{1-W_1}$  \\\midrule
H4  & $1-W_1$ \\\midrule
H5  & $\dfrac{W_1-1}{W_1}$ \\\midrule
H6  & $\dfrac{W_1}{W_1-1}$\\\bottomrule

\end{tabular}
\end{table} 

\end{document}
10
  • Thanks, it looks much nicer.
    – hana
    May 31, 2022 at 7:24
  • Not that improtant but in the second column at H3 and H4, 1-W1 aren't aligned. I understand that is due to the fraction line is longer than text expression. Is it possible to force to text to aligned
    – hana
    May 31, 2022 at 7:28
  • @hana, the expressions are aligned, but to the left, check the parameter l for the second column. You probably mean or want a center alignment.
    – FHZ
    May 31, 2022 at 7:37
  • 3
    @hana as FHZ says I'd use a centred column here. I would also (never) use [!h] which means not top not bottom not on a page on its own, so gives latex almost no chance to set the table and usually produces a warning that it is being changed to ht May 31, 2022 at 7:40
  • 6
    @hana the site doesn't really support asking new questions as comments, it doesn't really have any answer other than "whatever you want" in a formal document midrule is fine, other less formal alternatives include giving coloured background panels to the table (colortbl package) or a new 1st column with a group "heading" or .... May 31, 2022 at 8:23
9

Please tell me if you have any idea to make it look nicer.

In addition to the use of \dfrac, I played around with the table structure a bit to make better use of the full textwidth within the assumed two-column layout of IEEEtran:

layouted Table 1: Test Functions with 6 columns, 3 rows and several lines of lorem ipsum text below and above

Additional tweaks:

  • Reduced \tabcolsep to make STTC, FUL column pairs bond tighter together
  • Added \hskip 3em between column pairs
  • Added \addlinespace around the midrules for more visual hierarchy between table rows and fraction lines

With that display order, it is easier to spot that H2, H4, H6 are simply the inverse of H1, H3, H5.

\documentclass[journal]{IEEEtran}
\usepackage{amsmath,amsfonts}
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\usepackage{booktabs}
\usepackage{lipsum}

\begin{document}
  \lipsum[2]
  \begin{table}[!h]
    \centering
    \caption{Test Functions}
    \label{tab:table1}
    \setlength{\tabcolsep}{3pt}
    \begin{tabular}{cc@{\hskip 3em}cc@{\hskip 3em}cc}
      \toprule
      STTC & FUL & STTC & FUL & STTC & FUL \\ 
      \midrule \addlinespace[.75em]
      H1 & $W_1$ & H3  & $\dfrac{1}{1-W_1}$ & H5  & $\dfrac{W_1-1}{W_1}$ \\ 
      \addlinespace[.75em] \midrule \addlinespace[.75em]
      H2  & $\dfrac{1}{W_1}$ &  H4  & $1-W_1$ & H6  & $\dfrac{W_1}{W_1-1}$ \\
      \addlinespace[.5em] \bottomrule
    \end{tabular}
  \end{table}
  \lipsum[3]
\end{document}
2
  • 4
    Very nice looking table but I'd move the change of \tabcolsep into the table environment such that it remains a local redefinition. With this code all tables are affected.
    – campa
    May 31, 2022 at 16:39
  • 1
    @campa: thanks for the suggestion, done!
    – ojdo
    Jun 1, 2022 at 8:23
5

In the second column you may define display style. Using tabularray package this is simple to do:

\documentclass[journal]{IEEEtran}
\usepackage{amsmath,amssymb}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}


\begin{document}
    \begin{table}[!h]
    \centering
    \caption{Test functions}
    \label{tab:table1}
\begin{tblr}{hline{1,2,Z} = 0.8pt, hline{3-Y}={dashed, 0.15pt}, %solid
             colspec={c Q[l,mode=dmath]}, % column is in math displaystyle 
             row{1} = {mode=text}         % first row is in text style
             }
STTC    & FUL                   \\  
H1      & W_1                   \\ 
H2      & \frac{1}{W_1}         \\ 
H3      & \frac{1}{1-W_1}      \\ 
H4      & 1-W_1                 \\ 
H5      & \frac{W_1-1}{W_1}    \\ 
H6      & \frac{W_1}{W_1-1}    \\
\end{tblr}
    \end{table}
\end{document}

You must log in to answer this question.

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