5

I have to write a document in Calibri. Please find my minimal example thereafter. The issue is when I include some math, the design looks "ugly".

Is there a way to change the serif math font and number to some SANS-SERIF which looks close to Calibri?

  \documentclass[11pt]{article}
    \usepackage{fontspec}
    \usepackage{xltxtra}
    \usepackage{lipsum}
    \setmainfont[Mapping=tex-text]{Calibri}
    \begin{document}


 \begin{table}
\begin{center}
\begin{tabular}{l c }
\hline
            & Model 1 \\
\hline
(Intercept) & $10.9983^{***}$ \\
            & $(0.0420)$      \\
a  & $0.0040^{**}$   \\
            & $(0.0016)$      \\
b         & $0.0053^{***}$  \\
            & $(0.0012)$      \\
c & $0.0052^{***}$  \\
            & $(0.0001)$      \\
\hline
R$^2$       & 0.9317          \\
Adj. R$^2$  & 0.9309          \\
Num. obs.   & 243             \\
\hline
\multicolumn{2}{l}{\scriptsize{\textsuperscript{***}$p<0.01$, 
  \textsuperscript{**}$p<0.05$, 
  \textsuperscript{*}$p<0.1$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}
\end{center}
\end{table}

Loremipsumdolorsitamet,consectetueradipiscingelit. Utpuruselit,ves?bu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam
arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula
augueeuneque.  

 \[
 \bar{x} = \frac{x_1+x_2+\cdots +x_n}{n}
 \]

\end{document}

enter image description here

  • 1
    There is no Unicode math sans serif font, at the moment. – egreg Dec 21 '13 at 14:42
  • 1
    this won't help with the "real" math, but it shouldn't be necessary to use math coding for the numbers in the table. for entries like (0.0016) try just removing the $ signs. since that column appears to be centered, those entries should align. and for an entry like 0.0053^{***}, try first removing the $ signs, and then code the *** as \rlap{***}. i don't use calibri, but most text fonts have the * located in a "super" position, and the \rlap{...} will hide their width, again making the entry the same length as the others. – barbara beeton Dec 21 '13 at 15:00
  • @barbarabeeton Hello yeah I was considering doing that. Is working well but as I use texreg package on R I get automatically the $ ... $ style. So I will see if someone has a better solution. If not I will manually make the changes and consider your solution which is finally working but takes just a bit more time... Thanks – S12000 Dec 21 '13 at 15:38
6

use unicode-math:

\documentclass[11pt]{article}
\usepackage{unicode-math}
\usepackage{lipsum}
\setmainfont[Mapping=tex-text]{Calibri}
\setmathfont{XITS Math}% for the symbols
\setmathfont[range=\mathup]{Calibri}
\setmathfont[range=\mathit]{Calibri-Italic}
\begin{document}

\begin{table}
\centering
\begin{tabular}{l c }
\hline
            & Model 1 \\
\hline
(Intercept) & $10.9983^{***}$ \\
            & $(0.0420)$      \\
a  & $0.0040^{**}$   \\
            & $(0.0016)$      \\
b         & $0.0053^{***}$  \\
            & $(0.0012)$      \\
c & $0.0052^{***}$  \\
            & $(0.0001)$      \\
\hline
R$^2$       & 0.9317          \\
Adj. R$^2$  & 0.9309          \\
Num. obs.   & 243             \\
\hline
\multicolumn{2}{l}{\scriptsize{\textsuperscript{***}$p<0.01$, 
  \textsuperscript{**}$p<0.05$, 
  \textsuperscript{*}$p<0.1$}}
\end{tabular}
\caption{Statistical models}\label{table:coefficients}
\end{table}

Loremipsumdolorsitamet,consectetueradipiscingelit. Utpuruselit,ves?bu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam
arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula
augueeuneque.  

 \[
 \bar{x} = \frac{x_1+x_2+\cdots +x_n}{n}
 \]

\end{document}

enter image description here

  • Hello, I get an error it says "font-not-found" The font XITS Math cannot be found. I use miktex on win 7 – S12000 Dec 21 '13 at 16:28
  • Then use \setmathfont{latinmodern-math.otf}. However, you should be able to load XITS Math with MikTeX's package manager. You can also comment this line out, then the default math symbols are used. – user2478 Dec 21 '13 at 16:59
  • Oh you right is working fine through the package admin. Thanks. Is working on my side – S12000 Dec 21 '13 at 17:14
5

There is no Unicode sans serif math font available. If your document uses math only marginally, then mathspec can help.

I use TeX Gyre Heros, because I don't have Calibri.

\documentclass[11pt]{article}

\usepackage{mathspec}

\usepackage{lipsum}

\setmainfont[Ligatures=TeX]{TeX Gyre Heros}
\setmathsfont(Digits,Latin,Greek){TeX Gyre Heros}

\begin{document}

\begin{table}
\centering

\begin{tabular}{l c }
\hline
            & Model 1 \\
\hline
(Intercept) & $10.9983^{***}$ \\
            & $(0.0420)$      \\
a  & $0.0040^{**}$   \\
            & $(0.0016)$      \\
b         & $0.0053^{***}$  \\
            & $(0.0012)$      \\
c & $0.0052^{***}$  \\
            & $(0.0001)$      \\
\hline
R$^2$       & $0.9317$          \\
Adj. R$^2$  & $0.9309$          \\
Num. obs.   & $243$             \\
\hline
\multicolumn{2}{l}{\scriptsize{\textsuperscript{***}$p<0.01$, 
  \textsuperscript{**}$p<0.05$, 
  \textsuperscript{*}$p<0.1$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}

\end{table}

\lipsum*[2]
\[
\bar{x} = \frac{x_1+x_2+\cdots +x_n}{n}
\]

\end{document}

Note some changes to your document: don't load xltxtra; don't use center inside table; Never leave a blank line before a displayed equation.

enter image description here

Possibly a better way to typeset your table is by using siunitx and booktabs:

\documentclass[11pt]{article}

\usepackage{mathspec}
\usepackage{siunitx}
\usepackage{booktabs}

\usepackage{lipsum}

\setmainfont[Ligatures=TeX]{TeX Gyre Heros}
\setmathsfont(Digits,Latin,Greek){TeX Gyre Heros}

\begin{document}

\begin{table}
\newcommand\tnote[1]{${}^{#1}$}
\centering

\begin{tabular}{
  l
  S[table-format=2.4,
    table-space-text-post=\tnote{***},
   ]
}
\toprule
            & {Model 1} \\
\midrule
(Intercept) & 10.9983\tnote{***}      \\
\addlinespace[-.4ex]
            & {\footnotesize(0.0420)} \\
a           & 0.0040\tnote{**}        \\
\addlinespace[-.4ex]
            & {\footnotesize(0.0016)} \\
b           & 0.0053\tnote{***}       \\
\addlinespace[-.4ex]
            & {\footnotesize(0.0012)} \\
c           & 0.0052\tnote{***}       \\
\addlinespace[-.4ex]
            & {\footnotesize(0.0001)} \\
\midrule
R$^2$       & 0.9317             \\
Adj. R$^2$  & 0.9309             \\
Num. obs.   & {243}              \\
\bottomrule
\multicolumn{2}{l}{\scriptsize{\textsuperscript{***}$p<0.01$, 
  \textsuperscript{**}$p<0.05$, 
  \textsuperscript{*}$p<0.1$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}

\end{table}

\lipsum*[2]
\[
\bar{x} = \frac{x_1+x_2+\cdots +x_n}{n}
\]

\end{document}

enter image description here

  • nice, but why even bother with coding the numbers in the column as math? they'd look much nicer with the decimal points aligned, and that doesn't need math coding. – barbara beeton Dec 21 '13 at 15:02
  • @barbarabeeton Probably you're right. Maybe the table was just by way of example. – egreg Dec 21 '13 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.