9

Some has suggested this is a duplicate question, but I do not think so, because I haven't been able to do it by reading the other posts. I have something like

\documentclass[a4paper,12pt]{book}
\usepackage{times}
\usepackage[T1]{fontenc}
\begin{document}
\begin{chapter}
\[
w_1 = ax + b
\]
\end{document}

The letter w in the equation appears in common math mode. I want it to appear in eulervm font. I remark: only the w must appear in eulervm font. How to do it? Thanks in advance.

  • Welcome to TeX.SX! Do you want all w in math mode to be in the Euler font or just that one? – egreg Mar 24 '15 at 23:39
  • Actually, I need a few of them. In a whole section. But I don't want to change the default w in math mode, because I also need it. – JDavidEC Mar 24 '15 at 23:42
  • What is the default math font supposed to be: Computer Modern or Times? – Mico Mar 24 '15 at 23:48
  • I assume it is Times. That's what I think. – JDavidEC Mar 24 '15 at 23:51
  • 1
    You shouldn't be using times, but mathptmx, or the math symbols will be in the (non compatible) Computer Modern font. However, the Euler w is quite similar to the Times w, so your choice doesn't seem to be good. – egreg Mar 24 '15 at 23:52
  • If w has specific meaning, you should define a macro to be consistent. – Werner Mar 24 '15 at 23:54
  • As an answer to @egreg, what do I have to do then to use mathptmx? And actually, I think the w in euler has a special typography that the normal mode does not have. – JDavidEC Mar 24 '15 at 23:57
  • As a comment to @Werner, can you please explain? What do you mean by special meaning? – JDavidEC Mar 24 '15 at 23:58
  • @JDavidEC: If w represents (say) a vector and you want to denote vectors using a different font. Or, if w represents (say) some "wacky constant", you may want to be consistent in its representation. – Werner Mar 25 '15 at 00:00
  • @Werner w represents a word. And I want to do it this way, because I lready use a w for a constant, and \mathbb{w} for a vector. – JDavidEC Mar 25 '15 at 00:03
  • @JDavidEC: So make sure all words are formatted similarly inside math by defining a macro \word that formats its argument accordingly. – Werner Mar 25 '15 at 00:06

2 Answers2

5

The package times has been obsolete for several years; with it the math will still be typeset with Computer Modern that horribly clashes with Times New Roman.

Either use mathptmx or, much better, newtxtext and newtxmath.

However, it turns out that the Euler “w” is not very distinct from the Times italic ”w”, so perhaps you can use the bold version of the Euler letter.

\documentclass[a4paper,12pt]{book}
\usepackage[T1]{fontenc}
% for Times in text and math
\usepackage{newtxtext,newtxmath}
% or the following
%\usepackage{mathptmx}

\DeclareSymbolFont{eulerletters}{U}{zeur}{b}{n}
\DeclareMathSymbol{\eulw}{\mathord}{eulerletters}{`w}

\begin{document}
\[
\eulw_1 = ax + b - w
\]
\end{document}

enter image description here

This is how it would be with a medium Euler “w”, obtained by changing the code above in

\DeclareSymbolFont{eulerletters}{U}{zeur}{m}{n}

enter image description here

My opinion is that in both cases your readers will not appreciate the distinction.

Maybe using \mathsf{w} would be a better choice

\[
\mathsf{w}_1 = ax + b - w
\]

would produce

enter image description here

egreg
  • 1,121,712
  • your solution for the w works perfect too !! Thank you so much. But the packages for the fonts changes few things (like \hat{R}, for example). – JDavidEC Mar 25 '15 at 00:42
  • @JDavidEC It changes things, because it uses Times for math. – egreg Mar 25 '15 at 08:21
3

This seems to work. But it might be the worse way (better wait for a pro answer), I don't really know what I'm doing.

You might want to look at this question.

\documentclass{scrbook}
\usepackage[T1]{fontenc}
%\usepackage{newtxtext,newtxmath}
\usepackage{lmodern}

\DeclareSymbolFont{euletters}       {U}{zeur}{m}{n}
\SetSymbolFont{euletters}{bold}     {U}{zeur}{b}{n}
\DeclareMathSymbol\eulerw{\mathalpha}{euletters}{`\w}

\def\enableeulerw
  {\edef\disableeulerw{\mathcode`w=\the\mathcode`\w}\mathcode`\w="8000 }
\def\disableeulerw{}
\begingroup\lccode`~=`w\lowercase{\endgroup\let~}\eulerw


\begin{document}

\section{Foo}
\[
  w_1 = ax + b
\]
\section{Bar}
\enableeulerw
\[
  w_1 = ax + b
\]
\disableeulerw
\section{Baz}
\[
  w_1 = ax + b
\]

\end{document}

enter image description here

Manuel
  • 27,118