3

How do set the table body math part only different font using XeLaTeX. My MWE is:

\documentclass[a4paper,10pt]{article}

        \usepackage[margin=1in, showframe, nomarginpar]{geometry}
        \usepackage{chngcntr}
        \counterwithin{table}{section}
        \usepackage{tabularx}
        \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
                    \usepackage{colortbl}
                    \usepackage[svgnames]{xcolor}
                    \usepackage{makecell}
                    \usepackage{fontspec}
                    \newfontfamily\tablefont[Color=IndianRed, Numbers={Monospaced,Lining}]{Myriad Pro}
                    \usepackage{etoolbox}
                    \AtBeginEnvironment{table}{\setmainfont[Color=SteelBlue, Numbers={Proportional,OldStyle}]{Myriad Pro}}%
                    \AtBeginEnvironment{tabular}{\arrayrulecolor{LightSteelBlue}\tablefont\fontsize{9}{11}\selectfont\renewcommand{\theadfont}{\bfseries}}%

        \title{Paper 1}

        \begin{document}
        \maketitle

        \section{Dati}

        \begin{table}[htb!]
        \centering
        \begin{tabular}{L{2cm}|L{10cm}}
            \hline
           \thead{Variabili} & \thead{Descrizione} \\
            \hline
            \thead{$\alpha + \beta$} & \thead{$a+b$}\\
            \hline
        gdp\_us & GDP USA trimestrale nominale (dal Q1 1947 al Q4 2013), fonte: FRED2\\
            \hline
        \end{tabular}
        \caption{N/A}
        \label{tab2.1}
        \end{table}

        \end{document}
Balaji
  • 2,282

1 Answers1

4

You can load unicode-math and define

\setmathfont{Latin Modern Math}
\setmathfont[version=table]{XITS Math}

The former is the font to be used all over the document, the latter is the one to be used inside your tabulars by issuing

\mathversion{table}

Change the fonts to the ones you like (choose one with math support...)

MWE

\documentclass[a4paper,10pt]{article}

        \usepackage[margin=1in, showframe, nomarginpar]{geometry}
        \usepackage{chngcntr}
        \counterwithin{table}{section}
        \usepackage{tabularx}
        \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
                    \usepackage{colortbl}
                    \usepackage[svgnames]{xcolor}
                    \usepackage{makecell}
                    \usepackage{fontspec}
                    \usepackage{unicode-math}
                    \setmathfont{Latin Modern Math}
                    \setmathfont[version=table]{XITS Math}
                    \newfontfamily\tablefont[Color=IndianRed, Numbers={Monospaced,Lining}]{Myriad Pro}
                    \usepackage{etoolbox}
                    \AtBeginEnvironment{table}{\setmainfont[Color=SteelBlue, Numbers={Proportional,OldStyle}]{Myriad Pro}}%
                    \AtBeginEnvironment{tabular}{\arrayrulecolor{LightSteelBlue}\mathversion{table}\tablefont\fontsize{9}{11}\selectfont\renewcommand{\theadfont}{\bfseries}}%

        \title{Paper 1}

        \begin{document}
        \maketitle

        \section{Dati}

        \begin{table}[htb!]
        \centering
        \begin{tabular}{L{2cm}|L{10cm}}
            \hline
           \thead{Variabili} & \thead{Descrizione} \\
            \hline
            \thead{$\alpha + \beta$} & \thead{$a+b$}\\
            \hline
        gdp\_us & GDP USA trimestrale nominale (dal Q1 1947 al Q4 2013), fonte: FRED2\\
            \hline
        \end{tabular}
        \caption{N/A}
        \label{tab2.1}
        \end{table}

        Outside the table $\alpha + \beta$

        \end{document} 

Output

enter image description here

karlkoeller
  • 124,410