2

I am trying to set OpenSans Light as the default font in my document of type scrreport, so I included the opensans package. This worked so far, as that OpenSans is now used for my continuous text, but with the regular weight. Furthermore, some other parts apparently don't use it. See this screenshot for illustration:

enter image description here

Here is the markup:

\documentclass[
  paper = a4,
]{scrreprt}

\usepackage{lipsum} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[default,scale=0.95]{opensans}
\usepackage{lmodern}

\begin{document}
\linespread{1.25}\selectfont

\chapter{Test Chapter}

\section{Test Section}

\begin{description}
    \item [Some description] Some text...
    \item [Some description] Some text...
\end{description}

This is some text and some \textbf{bold} text and some \textit{italic} text.
\lipsum

\end{document}

First of all I'd like to have the continuous text in the light variant of the font. I could just do \fontseries{l}\selectfont at the beginning of my document, but I'm not sure if that is good style. Is there a way to define what the default weight of the standard font should be?

Next, please have a look at the things I circled in red; you will notice that these appear to be in LaTeX' default sans-serif font and not in the one I selected. However, the text circled in green is rendered with the OpenSans font. Now I'd like to change the font and font weight used in the headings, sections and descriptions to be e.g. OpenSans Light or Semibold. Preferrably I'd just set that font globally for everything. How can I achieve this?

EDIT: The font problem has been solved! I accidentially included that package lmodern which also replaced the default font for some elemnts. However, I'd still like to know how to change the weight of the font for the different elements.

Here is an updated screenshot of what the current state is:

enter image description here

1

Option defaultsans of package opensans sets the OpenSans font family as default sans-serif font family (\sfdefault). Option default additionally redefines \familydefault to \sfdefault. So option default is enough to change the font of the text and the other elements of a KOMA-Script document to OpenSans.

To change the weight of the text you can redefine \seriesdefault to l:

\renewcommand\seriesdefault{l}% use l(ight) as default series

And you can set \mddefault to l and bfdefault to sb (semibold) or m (regular).

\documentclass{scrreprt}
\usepackage{lipsum}

\usepackage[default,scale=0.95]{opensans}
\renewcommand\seriesdefault{l}
\renewcommand\mddefault{l}
\renewcommand\bfdefault{sb}% or \renewcommand\bfdefault{m}

\begin{document}
\chapter{Test Chapter}
\section{Test Section}

\begin{description}
    \item [Some description] Some text...
    \item [Some description] Some text...
\end{description}

This is some text and some \textbf{bold} text and some \textit{italic} text.
\lipsum{1}
\end{document}

Result with \renewcommand\bfdefault{sb}:

enter image description here

Result with \renewcommand\bfdefault{m}:

enter image description here

  • Thanks a lot, this is what I was looking for! I additionally used \addtokomafont{chapter}{...} etc. to customise headings and sections. However, I didn't know you could leave out the braces after renewcommand, i.e. I thought it should be \renewcommand{\seriesdefault}{l}. – bweber May 7 '16 at 18:25
2

The koma classes use sans serif fonts by default for all title fonts.

When you call the opensans package with the default option it replaces the normal (serif) font but doesn't touch the sans font.

Therefore you need to add the defaultsans option to also replace the sans serif font.

\documentclass{scrreprt}
\usepackage{lipsum}
\usepackage[default,defaultsans,scale=0.95]{opensans}

\begin{document}
\chapter{Test Chapter}

\section{Test Section}

\begin{description}
    \item [Some description] Some text...
    \item [Some description] Some text...
\end{description}

This is some text and some \textbf{bold} text and some \textit{italic} text.
\lipsum{1}
\end{document}

enter image description here

EDIT

looking at your updated source, you should remove the \usepackage{lmodern} as that also changed the definitions of the default fonts. The defaultsans should not be necessary.

  • I just found my mistake: I was including the package lmodern which also canges the font. Removing that produces the same result as you have. However, I think default is sufficient, because it replaces all the fonts whereas defaultsans only replaces the sans-serif font. But thanks, you made me realise my mistake. However, I still don't know how to adjust the weight of the font for the different elements. – bweber May 7 '16 at 13:14

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.