3

How do I change the boldness of my font to semibold ? Below is the initialization of the code that I copied online for my CV. I am very new to latex so I understand close to nothing as of now. I hope someone can give me a short and simple solution regardless of how unprofessional it is. My CV is fine. I just need to edit the boldness.

I have tried the links below but I keep getting an error.

Set the "font-weight: lighter/ bolder"

Can any of fontenc, inputenx, txfonts, mathptmx, newunicodechar support semi-bold?

\documentclass[11pt,a4paper]{moderncv}

\moderncvtheme[blue]{classic}

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[croatian]{babel}

\usepackage{hyphenat}

\usepackage[scale=0.75]{geometry}
\setlength{\hintscolumnwidth}{3.2cm}
\recomputelengths

\fancyfoot{}
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[RE,LO]{\footnotesize }

% personal datas
\firstname{}
\familyname{}
\address{}{}
\mobile{}              
\email{} 
\photo[]{}

\AtBeginDocument{
    \hypersetup{pdfborder = 0 0 1,colorlinks=false,linkbordercolor=blue,urlcolor=blue}
}

\nopagenumbers{} % uncomment to suppress automatic page numbering for CVs longer than one page

\usepackage{lmodern}
  • 2
    Since you are using the Latin Modern fonts, I suggest you \usepackage{cfr-lm} instead of \usepackage{lmodern} which gives you a nice interface to access all font features available with Latin Modern. Search the documentation for \sbweight or \textsb. – Arash Esbati Apr 25 '16 at 19:33
  • 1
    @ArashEsbati - You should write up an answer to formalize the information provided in the comment. – Mico Apr 25 '16 at 19:56
  • 1
    @Mico - Thanks for motivating; I was somewhat lazy and thought I can solve this with a comment ;-) – Arash Esbati Apr 25 '16 at 20:19
  • @Mico Actually, it isn't much help with this class, unfortunately. At least, not that I could tell. cfr-lm plus a sledge hammer seems to work, but without the sledge hammer cfr-lm is pretty useless. – cfr Apr 26 '16 at 1:14
5

For the record, I made substantial efforts to do this cleanly and failed utterly. moderncv hard codes numerous uses of bold and the use of the hooks provided by tweaklist have virtually no effect for our purposes.

So, this is not a good way to do this, but it may suffice.

Caveat emptor.

As recommended by Arash Esbati, we first load cfr-lm. However, we probably don't want the package's defaults. If lmodern is acceptable aside from the boldness, let's try this instead:

\usepackage[rm={lining,proportional},sf={lining,proportional},tt={lining,tabular,monowidth}]{cfr-lm}

This keeps lining figures, although it does use proportional for sans and serif. The typewriter family is set to use tabular lining figures and the monospaced variant of typewriter.

lmodern uses tabular lining figures throughout. cfr-lm uses proportional lining by default and variable typewriter. Proportional lining figures will look significantly better for sans and serif, but you can say tabular if you prefer the standard ugliness.

Now, ideally, we would now just tell moderncv which fonts to use for what. Unfortunately, that seems not possible, so we'll either have to rewrite large parts of the package or use a dirty hack.

I went with the hack:

\global\let\bfseries\sbweight

This will use the semi-bold fonts in place of the bold extended ones.

Note that this has some limitations. If we use bold italics, we will not get semibold oblique because genuine italics are not available in this weight.

Moreover, there are some less obvious limitations such as our having fewer optical sizes. This won't be a huge problem but it means the shapes of our characters will not be adjusted as sensitively according to size. Optical sizes make fonts easier to read at smaller sizes by using thicker strokes. Instead, a standard size will be scaled up or down, keeping the same shape.

Note, too, that \bfseries changes two aspects of the current font. First, it changes the weight to bold. Second, it changes the width to extended. (Actually, it isn't this simple, but that's enough for our purposes as we're concerned with Latin Modern and not the rest of the TeX font world.)

\sbweight changes one aspect of the font: the weight. It does not change the width. It doesn't matter whether we like this or not because Latin Modern doesn't offer semibold extended (or bold non-extended, for that matter). But our bold will look narrower as well as lighter than with the default configuration.

Here's the result of your preamble + my modifications + a bunch of content from moderncv's templatex.tex.

hacked CV

Complete code:

\documentclass[11pt,a4paper]{moderncv}
\moderncvtheme[blue]{classic}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}% don't use utf8x !!
\usepackage[croatian]{babel}
\usepackage{hyphenat}
\usepackage[scale=0.75]{geometry}
\setlength{\hintscolumnwidth}{3.2cm}
\recomputelengths
\fancyfoot{}
% \fancyfoot[LE,RO]{\thepage}% if you switch off page numbering belos, this makes no sense!
% \fancyfoot[RE,LO]{\footnotesize}

% personal datas
\firstname{Meg}
\familyname{Magik}
\address{The Haunted Web}{5 West Coven Grove}
\mobile{777 777--7777}
\email{mmagik@haunted.web.org}
\photo{cauldron}

\AtBeginDocument{%
  \hypersetup{pdfborder = 0 0 1,colorlinks=false,linkbordercolor=blue,urlcolor=blue}%
}
\nopagenumbers{} % uncomment to suppress automatic page numbering for CVs longer than one page

\usepackage[rm={lining,proportional},sf={lining,proportional},tt={lining,tabular,monowidth}]{cfr-lm}
\global\let\bfseries\sbweight
\begin{document}
% from moderncv's template.tex
\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}  % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}

\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description no longer than 1--2 lines.\newline{}%
Detailed achievements:%
\begin{itemize}%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
  \begin{itemize}%
  \item Sub-achievement (a);
  \item Sub-achievement (b), with sub-sub-achievements (don't do this!);
    \begin{itemize}
    \item Sub-sub-achievement i;
    \item Sub-sub-achievement ii;
    \item Sub-sub-achievement iii;
    \end{itemize}
  \item Sub-achievement (c);
  \end{itemize}
\item Achievement 3.
\end{itemize}}
\cventry{year--year}{Job title}{Employer}{City}{}{Description line 1\newline{}Description line 2}
\subsection{Miscellaneous}
\cventry{year--year}{Job title}{Employer}{City}{}{Description}

\section{Languages}
\cvitemwithcomment{Language 1}{Skill level}{Comment}
\cvitemwithcomment{Language 2}{Skill level}{Comment}
\cvitemwithcomment{Language 3}{Skill level}{Comment}

\section{Computer skills}
\cvdoubleitem{category 1}{XXX, YYY, ZZZ}{category 4}{XXX, YYY, ZZZ}
\cvdoubleitem{category 2}{XXX, YYY, ZZZ}{category 5}{XXX, YYY, ZZZ}
\cvdoubleitem{category 3}{XXX, YYY, ZZZ}{category 6}{XXX, YYY, ZZZ}

\section{Interests}
\cvitem{hobby 1}{Description}
\cvitem{hobby 2}{Description}
\cvitem{hobby 3}{Description}

\section{Extra 1}
\cvlistitem{Item 1}
\cvlistitem{Item 2}
\cvlistitem{Item 3. This item is particularly long and therefore normally spans over several lines. Did you notice the indentation when the line wraps?}

\section{Extra 2}
\cvlistdoubleitem{Item 1}{Item 4}
\cvlistdoubleitem{Item 2}{Item 5\cite{book1}}
\cvlistdoubleitem{Item 3}{Item 6. Like item 3 in the single column list before, this item is particularly long to wrap over several lines.}

\section{References}
\begin{cvcolumns}
  \cvcolumn{Category 1}{\begin{itemize}\item Person 1\item Person 2\item Person 3\end{itemize}}
  \cvcolumn{Category 2}{Amongst others:\begin{itemize}\item Person 1, and\item Person 2\end{itemize}(more upon request)}
  \cvcolumn[0.5]{All the rest \& some more}{\textit{That} person, and \textsb{those} also (all available upon request).}
\end{cvcolumns}
\end{document}
| improve this answer | |
  • You wrote, "\sbweight changes one aspect of the font: the weight. It does not change the width." Isn't that a good thing, in all likelihood? In addition, for all we know -- and this is of course rank speculation, since the OP has provided zero information so far on the subject -- oldstyle numbers may be preferable for the OP's purposes... – Mico Apr 26 '16 at 5:20
  • @Mico My point was just that doing this - versus loading lmodern - changes more than the weight. In a CV, osf are likely not going to be wanted in several places e.g. post codes or zips, telephone numbers etc. Years can look OK but I think that this particular style will not, with the years set off to the left as distinct blocks. But, really, I'm going by the fact that the OP was quite specific about wanting to change only the boldness. OSF are an acquired taste. I like them, but they are not very commonly used. – cfr Apr 26 '16 at 11:56
  • @cfr - First of all, kudos for generating a working example. This is something I was not willing to do. Reg. your proposed solution: I think there is also another solution without the sledge hammer: instead of \global\let\bfseries\sbweight which would also affect the other fonts, e.g. sans serif, one could do \usepackage{mweights} \makeatletter \def\bfseries@rm{sb} \makeatother besides \usepackage{cfr-lm}. I tested it briefly with your code and it works. – Arash Esbati Apr 26 '16 at 18:11
  • Thanks. This worked perfectly. Time I started learning how to use latex – RuiQi Apr 27 '16 at 16:56
  • @ArashEsbati I do not recommend doing that as I think it will break much of what cfr-lm offers. I haven't actually tested this, but, looking at the code, it does not seem compatible with nfssext-cfr. – cfr Apr 27 '16 at 19:30
5

Please always post a mininal working example which can be compiled just by copy/pasting into an editor.

To your question, I suggest you use cfr-lm.sty instead of lmodern.sty which provides a better interface to the fonts. You are looking for \sbweight. Code:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{lipsum,geometry} 
\usepackage{cfr-lm}
\frenchspacing

\begin{document}
\lipsum[1]
{\sbweight \lipsum[1]}
{\bfseries \lipsum[1]}    
\end{document}

enter image description here

| improve this answer | |
  • I think you need to explain how to load the package without altering the numerals. If the OP is using lmodern, then they may want to stick with tabular lining figures or switch to proportional lining. Hanging can work in a CV but only if you take care to switch to lining in appropriate places. For somebody new to LaTeX, I'd recommend loading with proportional lining for sans and serif. Typewriter is probably less useful in a CV, but lining of some kind may well be needed for email addresses or URLs. – cfr Apr 26 '16 at 0:10
  • Actually, this is not going to really work because the class hard codes the bold all over the place, so brute force and ignorance (as illustrated in my answer below) is required, I think. – cfr Apr 26 '16 at 1:12
2

I’m a couple of years late, but this question still came up in a search. The previous answers only work for legacy encodings, and it’s highly likely that anyone who wants to make a CV in LaTeX in the future will want to select a different font than the default.

Most professionals I’ve heard recommend against using several different weights of the same font in the same document, so I’m guessing you’re asking how to make \bfseries and \textbf{} give you semibold instead of bold. (If you do want a separate \sbseries and \textsb{} that work with fontspec, I have those too.)

With Package Options

If you search the OTF Fonts tag on CTAN, you’ll find a list of packages that in some way support OpenType fonts. Some of them just dump free .OTF files in a subdirectory of your distro. Some consist of a .STY font intended for use with commercial fonts that they can’t distribute.

Some, however, have a nice package that sets up the font for you. When the font family includes semibold weight, most of these offer a [sb] or [semibold] package option to swap semibold for bold.

\usepackage[osf, sb]{libertine}

A partial list of other packages that (claim to) support this as of August 2018 include libertinus-otf, plex-serif, plex-sans, noto-serif, noto-sans and sourcesanspro.

Using fontspec Commands

If you don’t have a package to load a font for you, you’ll have to use \setmainfont or \newfontfamily in fontspec. For example, there is an ebgaramond package, but it supports only the medium weight and sets bold to regular! If you download the font family from GitHub, you can instead load the family with:

\documentclass[varwidth, preview]{standalone}
\usepackage{fontspec}

\setmainfont[
  Scale = 1.0,
  Ligatures={Common, Discretionary, TeX},
  Numbers=OldStyle,
  UprightFont = *-Regular ,
  BoldFont = *-SemiBold ,
  ItalicFont = *-Italic ,
  BoldItalicFont = *-SemiBoldItalic ,
  Extension = .otf
]{EBGaramond}

\begin{document}
EB Garamond \textbf{bold \textit{Italic.}}
\end{document}

Patching a Package

In some cases, you can patch a font definition in a package, using \defaultfontfeatures[\rmdefault]{ BoldFont = ... } before you load it, but this will not work if the package specifies a bold font.

Since the ebgaramond package does set BoldFont = and BoldItalicFont = to the normal weights, we can’t override those with \defaultfontfeatures. We can, however, add additional font commands, such as a new series:

\documentclass[varwidth, preview]{standalone}
\usepackage{fontspec}

\defaultfontfeatures[\rmdefault, EBGaramond12]{
  Scale=MatchLowercase,
  FontFace = {sb}{n}{ Font = {EBGaramond-SemiBold},
                      Extension = .otf },
  FontFace = {sb}{it}{ Font = {EBGaramond-SemiBoldItalic},
                       Extension = .otf }
}

\DeclareRobustCommand\sbseries{\fontseries{sb}\selectfont}
\DeclareTextFontCommand{\textsb}{\sbseries}

\usepackage{ebgaramond}

\begin{document}
EB Garamond \textsb{semibold \textit{Italic.}}
\end{document}
| improve this answer | |

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.