# Redefine font used in \mathit

I am using the libertine package with pdflatex. For maths I use the Computer Modern font. In formulas I need longer variable names and to do get the spacing right I use \mathit. The font used is however Computer Modern which is fine for one-letter variables but looks a bit odd for longer ones (the short and long variables are used for semantically different objects so a difference in font should not be too upsetting). What is the correct way of globally redefining the font set by \mathit? Right now I have

\renewcommand{\mathit}[1]{\text{\itshape #1}}


which looks like a hack. Is there a better way? Which unwanted side-effects could my solution cause?

• Using Computer Modern for math with Libertine as main text font can take you before the Spanish Inquisition and you could be sentenced to the comfy chair. Be advised. – egreg Mar 19 '15 at 20:50
• why not simply use \textit – David Carlisle Mar 19 '15 at 20:53
• I would (a) define a macro named (say) \V, as \newcommand\V[1]{\textit{#1}}, in the preamble and (b) write \V{VarName1}, \V{VarName2}, etc in the body of the document. – Mico Mar 19 '15 at 21:31
• I'd recommend \usepackage[libertine]{newtxmath}. – egreg Mar 19 '15 at 21:42

Using Computer Modern for math with Libertine as main text font can take you before the Spanish Inquisition and you could be sentenced to the comfy chair. Be advised. ;-)

You can do much better: the package newtxmath accepts the option libertine and provides math symbols that go along well with Linux Libertine.

\documentclass{article}
\usepackage{amsmath}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}

\newcommand{\V}[1]{\mathit{#1}}

\begin{document}

\noindent
Some text before a silly formula $\sin x+\V{VarA}-\V{VarB}=\cos t$
and some text after it.

\end{document}


If you compare it with the output from

\documentclass{article}
\usepackage{amsmath}
\usepackage{libertine}

\newcommand{\V}[1]{\textnormal{\itshape#1}}

\begin{document}

\noindent
Some text before a silly formula $\sin x+\V{VarA}-\V{VarB}=\cos t$
and some text after it.

\end{document}


you'll see what I mean in my first paragraph.

• +1 for the first paragraph. +1 for a fine answer. -1 for enablement :P – Au101 Jul 4 '15 at 22:39
• @egreg yes I see why mixing the two styles in a formula is dreadful. What I was aiming for was using symbols (e.g. \to, =, \subseteq...) and as variables only \V{...} names. If I use CM only then I get a suboptimal mix of fonts when I mention \V names in the main text...but I do not like libertine as a math font for its thickness and kerning... – Bordaigorl Jul 5 '15 at 9:29