1

My document's main text is set as follows:

\renewcommand{\familydefault}{\sfdefault}       % sans serif to default
\usepackage[defaultsans,osfigures,scale=1]{opensans}  % change main font here

So that the main body is the Open Sans font. I've styled section headings with the serif Computer Modern using sectsty. I created a new environment to make certain parts of the document (for example, page number, title, names on title page) Computer Modern as well with the following custom environment:

\newenvironment{compmod}{\fontfamily{cm}\selectfont}

And it works fine. Except, I want to make a new environment like above that is bold faced, (or styled as I please) as well, but the following does not work:

\newenvironment{compmod}{\fontfamily{cm}\fontseries{b}\selectfont}

I've tried a few other things to no avail. My hunch is that because I set the main font to another family (and sans-serif), there is some clashing.

Any insight is appreciated.

  • Welcome to TeX SX! Did you try with \rmdefault? – Bernard Apr 23 at 19:39
  • 1
    you have not provided a usable test file nor shown a log file of the error, but there is not normally a cm family, there are cmr and cmss families, also the bold is usually bx (bold extended) rather than b – David Carlisle Apr 23 at 19:48
  • There are no errors. But you answered my question by suggesting cmr. Thank you! – likethevegetable Apr 23 at 19:54
  • Not errors but there must have been font substitution warnings in the log detailing the font you specified is not available and specifying the fallback fonts being used. – David Carlisle Apr 23 at 20:01
1

The choice of fonts seems disputable.

\documentclass{article}

\let\CMserif\rmdefault % save the default font family name

\usepackage[defaultsans,osfigures,scale=1]{opensans}  % change main font here
\usepackage{sectsty}

\renewcommand{\familydefault}{\sfdefault}

\allsectionsfont{\serifbold}

\newcommand{\serifbold}{\fontfamily{\CMserif}\bfseries}
\newenvironment{compmod}{\serifbold}{}

\begin{document}

\section{This title is serif}

This text is sans serif, \begin{compmod}and this is serif bold\end{compmod}.

\end{document}

enter image description here

If you scale down OpenSans, at least the height matches.

\documentclass{article}

\let\CMserif\rmdefault % save the default family name

\usepackage[defaultsans,osfigures,scale=0.82]{opensans}  % change main font here
\usepackage{sectsty}

\renewcommand{\familydefault}{\sfdefault}

\allsectionsfont{\serifbold} 

\newcommand{\serifbold}{\fontfamily{\CMserif}\bfseries}
\newenvironment{compmod}{\serifbold}{}

\begin{document}

\section{This title is serif}

This text is sans serif, \begin{compmod}and this is serif bold\end{compmod}.

\end{document}

enter image description here

  • Thank you for the tip on scaling to match the height (my hack was to simply adjust the document point size and enlarge the computer modern text). Are there any serif fonts you'd recommend that go well with CMR? (besides the default sans-serif) – likethevegetable Apr 24 at 14:09
  • @likethevegetable The choice of serif for titles and other inserts with the main text sans serif is quite unusual. – egreg Apr 24 at 14:14
0

There is not normally a cm family, there are cmr and cmss families, also the bold is usually bx (bold extended) rather than b

You did not say but on the terminal and in the log you presumably got a warning such as

LaTeX Font Warning: Font shape `OT1/cm/b/n' undefined
(Font)              using `OT1/cmr/m/n' instead on input line 5.

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.