[Tex/LaTex] CMBright for math and Iwona for text

fontsmath-modesans-serif

Is there a way to load packages Iwona and CMBright so that Iwona is used only for text, CMBright only for math, and all text and math is sans-serif?

The only command I've thought of so far are:

\usepackage{cmbright}
\usepackage{iwona}
\renewcommand*{\familydefault}{\sfdefault}
\SetSymbolFont{largesymbols}{normal}{OMX}{iwona}{m}{n}

And it's certainly not quite right.
Thanks in advance to anybody who shall try to help me.

P.S. I can provide complete code if anybody feels it's gonna be useful.

ETA:

Here's some basic document from which we can try to solve my problem:

\documentclass{article}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\usepackage[math]{iwona}
\usepackage{cmbright}

\renewcommand*{\familydefault}{\sfdefault}
\SetSymbolFont{largesymbols}{normal}{OMX}{iwona}{m}{n}

\begin{document}
    \section{A section}

    \begin{equation}
        S\!\left(x\right) = \mathsf{Pr}\!\left[X > x\right] \qquad \widehat{S}\!\left(t\right) = \textsf{exp}\!\left(-\widehat{H}\!\left(t\right)\right).
    \end{equation}

    \noindent \lipsum[1-1]
\end{document}

ETA:

We're almost there. The last thing that remains is the sections, subsections, and so forth font that is ultra bold and ugly, and as far as I know unrelated to Iwona. Is this a thing we can remedy? As for the body's font, I'd like the sections font to be Iwona's sans-serif… Thanks again!

ETA:

I think I found something really interesting for that last part:

\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large}}
\makeatother

\makeatletter
\renewcommand\subsection{\@startsection {subsection}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\large}}
\makeatother

\makeatletter
\renewcommand\subsubsection{\@startsection {subsubsection}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\normalsize}}
\makeatother

Somehow, that really seems to do it, so now if anybody has time for it, I'd would like to understand (even if only a little bit more) why mixing fonts like I did isn't a good idea. I promise to do my best to be open-minded about the semantic problem it engenders.

ETA:

OK, took some time to do more testing, and my last solution wasn't quite right after all. I have nonetheless been able to redeem myselft (at least I think) with teh following code:

\documentclass{article}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\usepackage[math]{iwona}
\usepackage{sfmath}

\renewcommand*{\familydefault}{\sfdefault}

\begin{document}
    \title{MY TITLE}
    \date{}

    \maketitle

    \section{A section}

    \section{Another section}

    \subsection{A subsection}

    \subsubsection{A subsubsection}

    \begin{equation}
        \begin{aligned}
            S\!\left(x\right) & \ = \ \mathsf{Pr}\!\left[X > x\right]\\
            H\!\left(x\right) & \ = \ \int_0^x h\!\left(t\right)\mathsf{d}t\\
        \end{aligned}
        \qquad
        \begin{aligned}
            \widehat{S}\!\left(t\right) & \ = \ \textsf{exp}\!\left(-\widehat{H}\!\left(t\right)\right)\\
            \widehat{H}\!\left(t\right) & \ = \ \sum_{k \, | \, t_k \leq t} d_k / n_k
        \end{aligned}
    \end{equation}

    \noindent \lipsum[1-1]
\end{document}

It has everything I wish for: sans-serif font, sans serif math, no ugly ultra bold sections font. The key is the package sfmath which does an amazing job.

That said, I would appreciate to be noticed if there somehow remains a ticking bomb hidden inside the document.

I would like to thanks anybody who tried to help me, especially cfr. Thank you mate. I mean it (it is very sad that my rep prevents me from upvoting you).

Best Answer

In no way do I recommend doing this as I think it is aesthetically extremely dubious, at best. However, this site is not concerned with whether things are typographically judicious but only with the most technically elegant implementations of them in TeX.

iwona sets the font up as the default roman family. cmbright sets up the font as the default sans family and then sets the default family to sans.

So, if we load iwona first, we can let cmbright overwrite the maths configuration, which will fall back to iwona's choices for e.g. OMX wheere these are not provided by CM Bright. (This is not a good idea but it seems to be what you have in mind.)

We can then switch the default family back to roman to obtain Iwona for text.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[math]{iwona}
\usepackage{cmbright}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\renewcommand*{\familydefault}{\rmdefault}

\begin{document}
  \begin{equation}
    \begin{aligned}
      H\!\left(x\right)
      & \ = \ \int_0^x h\!\left(t\right)\mathsf{d}t\\
      &\\
      \widehat{H}\!\left(t\right)
      & \ = \ \sum_{k \, | \, t_k \leq t} d_k / n_k\\
    \end{aligned}
    \qquad
    \begin{aligned}
      S\!\left(x\right)
      & \ = \ \mathsf{Pr}\!\left[X > x\right]\\
      &\\
      \widehat{S}\!\left(t\right)
      & \ = \ \textsf{exp}\!\left(-\widehat{H}\!\left(t\right)\right).
    \end{aligned}
  \end{equation}

  \noindent
  \lipsum[1-1]

\end{document}

Iwona and CM Bright

See cmbright's documentation for suggestions concerning suitable large symbols, such as cmex. These may go a bit better than mixing Iwona. But, since you are already mixing two sans fonts, perhaps large symbols are the least of your worries.

You should also consider a solution which involves replacing just the symbols you do not like. There are several questions of this kind on the site to use as guides.

EDIT: NOTES

If you use the following code:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[math]{iwona}
\usepackage{cmbright}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\renewcommand*{\familydefault}{\sfdefault}

\begin{document}
  \begin{equation}
    \begin{aligned}
      H\!\left(x\right)
      & \ = \ \int_0^x h\!\left(t\right)\mathsf{d}t\\
      &\\
      \widehat{H}\!\left(t\right)
      & \ = \ \sum_{k \, | \, t_k \leq t} d_k / n_k\\
    \end{aligned}
    \qquad
    \begin{aligned}
      S\!\left(x\right)
      & \ = \ \mathsf{Pr}\!\left[X > x\right]\\
      &\\
      \widehat{S}\!\left(t\right)
      & \ = \ \textsf{exp}\!\left(-\widehat{H}\!\left(t\right)\right).
    \end{aligned}
  \end{equation}

  \noindent
  \lipsum[1-1]

\end{document}

then you will get CM Bright for text and maths. The only exception is the large maths symbols, lacking from CM Bright, which will come from Iwona:

CM Bright with large Iwona maths symbols

I think in that case, you might be better off dropping Iwona altogether and using the configuration suggested in cmbright's documentation:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{cmbright}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\renewcommand*{\familydefault}{\sfdefault}

\begin{document}
  \begin{equation}
    \begin{aligned}
      H\!\left(x\right)
      & \ = \ \int_0^x h\!\left(t\right)\mathsf{d}t\\
      &\\
      \widehat{H}\!\left(t\right)
      & \ = \ \sum_{k \, | \, t_k \leq t} d_k / n_k\\
    \end{aligned}
    \qquad
    \begin{aligned}
      S\!\left(x\right)
      & \ = \ \mathsf{Pr}\!\left[X > x\right]\\
      &\\
      \widehat{S}\!\left(t\right)
      & \ = \ \textsf{exp}\!\left(-\widehat{H}\!\left(t\right)\right).
    \end{aligned}
  \end{equation}

  \noindent
  \lipsum[1-1]

\end{document}

CM Bright and CM Extended for large maths symbols

UPDATE

This is a response to the edited question. As I explain in a comment, the solution posted there is not a good one because it is not really doing what you think.

Let's start by examining the different fonts because this is causing some confusion:

font sampler

Code:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\begin{document}
  Default Computer Modern Roman (serif):

    \lipsum[1]

  \sffamily Computer Modern Sans Serif:

    \lipsum[1]

  \fontfamily{cmbr}\selectfont Computer Modern Bright:

    \lipsum[1]

  \fontfamily{iwona}\selectfont Iwona:

    \lipsum[1]
\end{document}

I gather from comments, that you do not actually like Iwona. That is, you do not want to use the last font in the sampler above. This is not 'Iwona serif' or 'Iwona roman'. It is just Iwona. If you don't like that font, you don't like Iwona.

Computer Modern Sans

What you wish to use, I think, is either Computer Modern Bright or Computer Modern Sans Serif. The code I gave earlier demonstrates how to use CM Bright. To use Computer Modern Sans Serif:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\renewcommand*{\familydefault}{\sfdefault}
\begin{document}

    \lipsum[1]

\end{document}

cmss

The complication in all this is that iwona.sty installs Iwona as the default roman/serif family even though Iwona is actually a sans serif font. So, if you load iwona but then switch to sans for the document, you don't actually see any Iwona in use for text at all. (Unless you explicitly request the roman family.)

I think what you really wish to do is to use the large maths symbols from Iwona to avoid the serif versions you otherwise get. And I'm not sure that is the best solution. However,...

Maths

What happens to maths? By default, nothing. All we've done is change the text font. As you explain, sfmath can be used to activate sans maths:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\usepackage{sfmath}
\renewcommand*{\familydefault}{\sfdefault}
\begin{document}

  \lipsum[1]

  \begin{equation}
    \begin{aligned}
      S\!\left(x\right) & \ = \ \mathsf{Pr}\!\left[X > x\right]\\
      H\!\left(x\right) & \ = \ \int_0^x h\!\left(t\right)\mathsf{d}t\\
    \end{aligned}
    \qquad
    \begin{aligned}
      \widehat{S}\!\left(t\right) & \ = \ \textsf{exp}\!\left(-\widehat{H}\!\left(t\right)\right)\\
      \widehat{H}\!\left(t\right) & \ = \ \sum_{k \, | \, t_k \leq t} d_k / n_k
    \end{aligned}
  \end{equation}

\end{document}

sans maths

This is taking large symbols from Computer Modern's cmex font, with letters and operators from the sans serif font.

Large Symbols from Iwona

If you would prefer to take the large symbols from Iwona, you can do this:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\usepackage{sfmath}% use cm, cmbright or lm as options for similar maths fonts (cm is default)
\renewcommand*{\familydefault}{\sfdefault}
% take large maths symbols from Iwona as these aren't available in Computer Modern for sans (otherwise we get serif symbols from cmex)
\SetSymbolFont{largesymbols}{normal}  {OMX}{iwona}{m}{n}
\SetSymbolFont{largesymbols}{bold}  {OMX}{iwona}{b}{n}
\begin{document}

  \lipsum[1]

  \begin{equation}
    \begin{aligned}
      S\!\left(x\right) & \ = \ \mathsf{Pr}\!\left[X > x\right]\\
      H\!\left(x\right) & \ = \ \int_0^x h\!\left(t\right)\mathsf{d}t\\
    \end{aligned}
    \qquad
    \begin{aligned}
      \widehat{S}\!\left(t\right) & \ = \ \textsf{exp}\!\left(-\widehat{H}\!\left(t\right)\right)\\
      \widehat{H}\!\left(t\right) & \ = \ \sum_{k \, | \, t_k \leq t} d_k / n_k
    \end{aligned}
  \end{equation}

\end{document}

Computer Modern Sans with sans maths and Iwona large symbols

Iwona, Bold and Computer Modern

The issue of bold sections is different. What happens if you load iwona is that it redefines the bold series

\renewcommand{\bfdefault}{b}

So the following document

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage[math]{iwona}
\usepackage{lipsum}
\usepackage{sfmath}% use cm, cmbright or lm as options for similar maths fonts (cm is default)
\renewcommand*{\familydefault}{\sfdefault}
% take large maths symbols from Iwona as these aren't available in Computer Modern for sans (otherwise we get serif symbols from cmex)
\SetSymbolFont{largesymbols}{normal}  {OMX}{iwona}{m}{n}
\SetSymbolFont{largesymbols}{bold}  {OMX}{iwona}{b}{n}
\begin{document}

  \textbf{bold} and normal text

\end{document}

will produce this:

disabled bold

That is, you cannot use bold at all. This happens because the far-from-ideal redefinition in iwona.sty interacts with the far-from-ideal default setup of the Computer Modern fonts. In fact, the manual for sfmath recommends loading fix-cm and doing so before \documentclass. Adding

\RequirePackage{fix-cm}

before \documentclass fixes the problem:

reinstate bold

So loading iwona merely to get non-bold sections is also going to kill bold everywhere. But fixing bold will also reinstate bold sections because if LaTeX can find bold fonts, it will use them for section headings by default. Moreover, it is likely to lead to inconsistencies in surprising places. It would be better to ask LaTeX for non-bold sections rather than hoping that LaTeX will be unable to find bold fonts at all.

Non-Bold Sections

The titlesec package can be used to achieve this easily. The following passes titlesec the sf and md options for sans serif, medium weight section headings. [Note that the options are sf and md rather than sffamily and mdseries i.e. they do not correspond to the LaTeX font commands \sffamily and \mdseries.]

\RequirePackage{fix-cm}% recommended in documentation for sfmath
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{lipsum}
\usepackage{sfmath}% use cm, cmbright or lm as options for similar maths fonts (cm is default)
\renewcommand*{\familydefault}{\sfdefault}
% take large maths symbols from Iwona as these aren't available in Computer Modern for sans (otherwise we get serif symbols from cmex)
\SetSymbolFont{largesymbols}{normal}  {OMX}{iwona}{m}{n}
\SetSymbolFont{largesymbols}{bold}  {OMX}{iwona}{b}{n}
\usepackage[sf,md]{titlesec}
\begin{document}

  \section{A section}

  \section{Another section}

  \subsection{A subsection}

  \subsubsection{A subsubsection}

  \lipsum[1]

  \begin{equation}
    \begin{aligned}
      S\!\left(x\right) & \ = \ \mathsf{Pr}\!\left[X > x\right]\\
      H\!\left(x\right) & \ = \ \int_0^x h\!\left(t\right)\mathsf{d}t\\
    \end{aligned}
    \qquad
    \begin{aligned}
      \widehat{S}\!\left(t\right) & \ = \ \textsf{exp}\!\left(-\widehat{H}\!\left(t\right)\right)\\
      \widehat{H}\!\left(t\right) & \ = \ \sum_{k \, | \, t_k \leq t} d_k / n_k
    \end{aligned}
  \end{equation}

\end{document}

Sans, medium sections, sans maths and text, large symbols from Iwona

Importantly, this preserves your ability to use bold when you wish:

\textbf{bold} and normal

bold and normal preserved

Note that even if you do not wish to use bold, loading iwona to get rid of it is not a good solution because some fonts (such as Iwona) do have a bold b series and you are likely to get weird things happening. Moreover, your logs and output on the console will complain frequently about missing fonts, making it harder to identify real issues which you do want to find.

Related Question