2

I am using a template from PNAS (http://www.pnas.org/site/authors/LaTex.xhtml) on sharelatex and when I am adding units like:

\SI{15}{\mL}

they are not scaled properly, as seen in the attached image.
Example of siunitx not scaled properly
Moreover, is there a way that I could force siunitx to use the surrounding fonts. I have tried to use in the preamble:

\sisetup{detect-weight=true, detect-family=true}

with no luck.
Any help would be appreciated.

Edit 1: Minimal example added

\documentclass{pnastwo}
\usepackage[dvips]{graphicx}
\usepackage{amssymb,amsfonts,amsmath}
\usepackage{gensymb,fixltx2e}
\usepackage{fontspec}
\usepackage{siunitx}
\sisetup{detect-weight=true, detect-family=true}

\begin{document}
\begin{article}
\begin{materials}
This is a minimal example. The following units \SI{15}{\mL} do not render with the same typeface and size as the surrounding text. 
\end{materials}
\end{article}
\end{document}
  • 1
    Can you add a minimal example from \documentclass to \end{document}? However, as far as I remember, the PNAS class uses a non standard system for fonts, which probably is responsible for tricking siunitx. – egreg Dec 20 '14 at 14:30
  • Have you switched to a font that does not include math symbols? – Peter Jansson Dec 20 '14 at 15:00
  • Related: tex.stackexchange.com/questions/185661/… – egreg Dec 20 '14 at 15:46
  • @egreg: I have just added an example to reproduce the problem. Thank you for the related article – jiko Dec 20 '14 at 15:59
  • As I told you, the pnastwo class uses a non standard method for fonts. In particular, the materials environment selects a font directly defined with the \font primitive, which makes packages that assume compliance with the standard font selection scheme fail. – egreg Dec 20 '14 at 16:04
3

The class doesn't use nfss to define fonts and so siunitx has absolutly no chance to detect the font (and as a side-warning: be careful with non-ascii chars. In the combination with xelatex/lualatex they can come out wrong or be missing all together). You can get around the problem by redefining the font commands:

\documentclass{pnastwo}

\usepackage{graphicx}
\usepackage{amssymb,amsfonts,amsmath}
\usepackage{gensymb,fixltx2e}
\usepackage{fontspec}
\renewcommand\materialfont{\sffamily\fontsize{7pt}{\baselineskip}\selectfont}
\usepackage{siunitx}
\sisetup{detect-weight=true, detect-family=true}

\begin{document}
\begin{article}
\begin{materials}
This is a minimal example. The following units \SI{15}{\mL} do not render with the same typeface and size as the surrounding text.
\end{materials}
\end{article}
\end{document}
  • I don't think this will be accepted by PNAS, because they seem to use proprietary fonts and they don't use the NFSS, because the fonts are encoded in a nonstandard way. – egreg Dec 20 '14 at 16:43
  • @egreg: Well the OP loads fontspec which is leads to an unstandard font setup anyway. Beside this the default value of \materialfont is cmss at 7pt, so the font (without fontspec) would be the same. – Ulrike Fischer Dec 20 '14 at 16:52
  • fontspec conforms to the NFFS, which is what I mean by "standard”. The pnastwo class defines \materialfont in that way just for the author's galley, but the final printout will use Frutiger. – egreg Dec 20 '14 at 16:52
  • 1
    @egreg: But it this case a document meant for submission shouldn't load fontspec at all. It will quite probably clash somewhere. – Ulrike Fischer Dec 20 '14 at 17:10
  • That goes without saying. – egreg Dec 20 '14 at 17:18
1

(Too long for a comment, hence posted as an answer of sorts.)

There must be something going on in your document setup you haven't told us about so far. The pnastwo document class does not, by itself, mess with fonts, at least not in a way that would affect the macros of the \siunitx package.

Please do tell us -- ideally in the form of an MWE -- how you go about changing the text font to sans-serif.

enter image description here

\documentclass{pnastwo}
\usepackage[detect-family=true]{siunitx}
\begin{document}
\sffamily
abc

\SI{15}{\milli\liter}
\end{document}
  • Try loading the pnastwof package, that's requested by the template. – egreg Dec 20 '14 at 15:01
  • @Mico: When I am adding \sffamily the whole paragraph changes typeface. I have edited my question adding an example. Thank you. – jiko Dec 20 '14 at 16:00

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.