tabularray icon indicating copy to clipboard operation
tabularray copied to clipboard

Setting font size for all tables

Open jankap opened this issue 2 years ago • 5 comments

I need to use a rather complex (and old) LaTeX template https://www.ieee.org/conferences/publishing/templates.html. It looks like the Font size in all tables is smaller than the rest of the text.

Can the font size been set globally in the template? I'm aware of the font attribute, but no idea how to set the size. The examples rather cover bold or italic, but not size :)

The relevant definition in the template might be

\def\tablefont{\fontencoding{T1}
   \fontfamily{phv}
   \fontseries{m}
   \fontshape{n}
   \fontsize{8}{10}
   \selectfont }

...

\newcounter{table}
\def\thetable{\@Roman\c@table}
\def\fps@table{tbp}
\def\ftype@table{2}
\def\ext@table{lot}
\def\fnum@table{\color{subsectioncolor}\sf TABLE~\thetable}
% V1.6 IEEE uses 8pt text for tables
% to default to footnotesize, we hack into LaTeX2e's \@floatboxreset and pray
\def\table{%
\newdimen\width
\setbox2=\hbox{\hphantom{\hspace*{255pt}}}
\width=\wd2 %\advance\width by \dp0%
\def\@floatboxreset{\reset@font\footnotesize\@setminipage}\@float{table}}
\def\endtable{\end@float}
% v1.6b double column tables need to default to footnotesize as well.
\@namedef{table*}{%
\newdimen\width
\setbox2=\hbox{\hphantom{\hspace*{516pt}}}
\width=\wd2 %\advance\width by \dp0%
\def\@floatboxreset{\reset@font\footnotesize\@setminipage}\@dblfloat{table}}
\@namedef{endtable*}{\end@dblfloat}

But interestingly, \tablefont is not used. Maybe I did search the wrong documents.

Thanks!

jankap avatar Nov 27 '23 20:11 jankap

I need to use a rather complex (and old) LaTeX template https://www.ieee.org/conferences/publishing/templates.html.

I can't find \tablefont in the IEEEtran.cls in https://www.ieee.org/content/dam/ieee-org/ieee/web/org/pubs/conference-latex-template_10-17-19.zip.

muzimuzhi avatar Nov 27 '23 23:11 muzimuzhi

The latest IEEEtran.cls downloaded from both the webpage you linked and TeX Live/MiKTeX (https://ctan.org/pkg/ieeetran) is versioned 1.8b. It seems you're using v1.6, which is outdated.

Using IEEEtran.cls v1.8b, you don't need to take care of table font sizes.

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}

\usepackage{tabularray}

% see https://github.com/lvjr/tabularray/discussions/396
\DefTblrTemplate{caption-sep}{default}{\par}
\DefTblrTemplate{caption}{default}{%
  \makebox[\tablewidth]{\parbox{\columnwidth}{%
    \UseTblrAlign{caption}%
    \UseTblrTemplate{caption-tag}{default}%
    \UseTblrTemplate{caption-sep}{default}%
    \UseTblrFont{caption-text}%
    \UseTblrTemplate{caption-text}{default}%
  }}%
}
\SetTblrStyle{caption}{halign=c}
\SetTblrStyle{caption-text}{font=\scshape}
\SetTblrStyle{note}{indent=\tabcolsep}

\begin{document}

\title{Conference Paper Title}

\maketitle

\section{Prepare Your Paper Before Styling}

\subsection{Figures and Tables}

\begin{table}[htbp]
  \caption{Table created by \texttt{tabular}}\label{tab1}
  \centering
  \begin{tabular}{|c|c|c|c|}
    \hline
    \textbf{Table}&\multicolumn{3}{|c|}{\textbf{Table Column Head}} \\
    \cline{2-4} 
    \textbf{Head} & \textbf{\textit{Table column subhead}}& \textbf{\textit{Subhead}}& \textbf{\textit{Subhead}} \\
    \hline
    copy& More table copy$^{\mathrm{a}}$& &  \\
    \hline
    \multicolumn{4}{l}{$^{\mathrm{a}}$Sample of a Table footnote.}
  \end{tabular}
  
  \bigskip

  \begin{talltblr}[
    caption={Table created by \texttt{talltblr}},
    footsep=2pt,
    note{a}={Sample of a Table footnote.}
  ]{
    colspec={cccc},
    hlines, vlines, 
    stretch=0,
    % rowsep=1pt, % mimic row sep
    cell{1}{1}={r=2}{},
    cell{1}{2}={c=3}{},
    row{1}={font=\bfseries},
    row{2}={font=\bfseries\itshape}
  }
    {Table \\Head} & Table Column Head \\
               & Table column subhead & Subhead & Subhead \\
    copy & More table copy\TblrNote{a}
  \end{talltblr}
\end{table}

\end{document}

image

muzimuzhi avatar Nov 27 '23 23:11 muzimuzhi

I need to use a rather complex (and old) LaTeX template https://www.ieee.org/conferences/publishing/templates.html.

I can't find \tablefont in the IEEEtran.cls in https://www.ieee.org/content/dam/ieee-org/ieee/web/org/pubs/conference-latex-template_10-17-19.zip.

You are right, I'm very sorry, pasted the wrong link. I tried both, the IEEE Conference Template and the Journal/Article template. I need to use the latter.

I.e., I'm following this link: https://template-selector.ieee.org/secure/templateSelector/publicationType, choose "journals", then "IEEE Sensors Journal" -> "Original Research and Brief" -> Latex -> Download Template

JSEN Latex.zip

The style is called "ieeecolor.cls" and can be found in the zip file, too. The header says

image

And in this file, you can find the \tablefont in line 2193: image

I could not find any never version, it seems to be a modified one, based on v1.6b.

Unfortunately, your MWE (huge thanks for that!) does not compile with ieeecolor (with IEEEtrans it does and I can reproduce your results). So I tried to modify it, but not luck:

% \documentclass[conference]{IEEEtran}
% \IEEEoverridecommandlockouts
% The preceding line is only needed to identify funding in the first footnote. If that is unneeded, please comment it out.

\documentclass[journal,twoside,web,letterpaper]{style/ieeecolor}
\def\logoname{attachments/LOGO-jsen-web}
\definecolor{subsectioncolor}{rgb}{0,0.44706,0.40392}
\setlength{\firstpagerule}{35.85pc}
\setlength{\logowidth}{7.15pc}
\def\journalname{IEEE Sensors Journal}

\usepackage{cite}
\usepackage{amssymb,amsfonts}

\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{amsmath}
\usepackage{subcaption}
\usepackage{caption}


\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}


% % see https://github.com/lvjr/tabularray/discussions/396
\DefTblrTemplate{caption-sep}{default}{\par}
\DefTblrTemplate{caption}{default}{%
  \makebox[\tablewidth]{\parbox{\columnwidth}{%
    \UseTblrAlign{caption}%
    \UseTblrTemplate{caption-tag}{default}%
    \UseTblrTemplate{caption-sep}{default}%
    \UseTblrFont{caption-text}%
    \UseTblrTemplate{caption-text}{default}%
  }}%
}
\SetTblrStyle{caption}{halign=c}
\SetTblrStyle{caption-text}{font=\scshape}
\SetTblrStyle{note}{indent=\tabcolsep}

\usepackage{wrapfig}


\definecolor{abstractbg}{rgb}{0.89804,0.94510,0.83137}
\setlength{\fboxrule}{0pt}
\setlength{\fboxsep}{0pt}
\begin{document}
\title{Title}

\maketitle

\begin{table}[htbp]
  \caption{Table created by \texttt{tabular}}\label{tab1}
  \centering
  \begin{tabular}{|c|c|c|c|}
    \hline
    \textbf{Table}&\multicolumn{3}{|c|}{\textbf{Table Column Head}} \\
    \cline{2-4} 
    \textbf{Head} & \textbf{\textit{Table column subhead}}& \textbf{\textit{Subhead}}& \textbf{\textit{Subhead}} \\
    \hline
    copy& More table copy$^{\mathrm{a}}$& &  \\
    \hline
    \multicolumn{4}{l}{$^{\mathrm{a}}$Sample of a Table footnote.}
  \end{tabular}
  \bigskip

  \begin{talltblr}[
    caption={Table created by \texttt{tblr}},
    note{a}={Sample of a Table footnote.}
  ]{
    colspec={cccc},
    hlines, vlines,
    stretch=0,
    % rowsep=1pt, % mimic row sep
    cell{1}{1}={r=2}{},
    cell{1}{2}={c=3}{},
    row{1}={font=\bfseries},
    row{2}={font=\bfseries\itshape}
  }
    {Table \\Head} & Table Column Head \\
               & Table column subhead & Subhead & Subhead \\
    copy & More table copy\TblrNote{a}
  \end{talltblr}
\end{table}

\end{document}

Error message:

(/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1pcr.fd)
(/root/texmf/tex/latex/amsfonts/umsa.fd)
(/root/texmf/tex/latex/amsfonts/umsb.fd)
! Undefined control sequence.
\l__tblr_template_caption-tag_default_tl ...ename 
                                                  \hspace {0.25em}\thetable 
l.88   \end
         {talltblr}
? 

If I replace talltblr by tblr (also from the tabularray package), it works, but there's no caption which is only supported by talltblr (at least when using the caption attribute).

image

jankap avatar Nov 28 '23 10:11 jankap

Also interesting, caption package interferes, too:

% \usepackage{caption} image

\usepackage{caption} image

jankap avatar Nov 28 '23 11:11 jankap

Regarding error from above:

Error message:

(/usr/share/texlive/texmf-dist/tex/latex/psnfss/ot1pcr.fd)
(/root/texmf/tex/latex/amsfonts/umsa.fd)
(/root/texmf/tex/latex/amsfonts/umsb.fd)
! Undefined control sequence.
\l__tblr_template_caption-tag_default_tl ...ename 
                                                  \hspace {0.25em}\thetable 
l.88   \end
         {talltblr}
? 

Just found out that this error goes away, wenn I add \usepackage{longtable}. Very weird.

image

The caption looks still different though.

jankap avatar Nov 28 '23 12:11 jankap

This is not a proper issue report.

lvjr avatar Nov 12 '24 03:11 lvjr