13

I want to use \lVert and \rVert to denote the vector norm. "Testing ||x||." in CM

With Computer Modern this works quite fine. But when trying to use Iwona as a math font, I run into trouble:

\documentclass{standalone}
\usepackage[math]{iwona}
\usepackage{mathtools}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\begin{document}
Testing $\norm{x}$.
\end{document}

"Testing x." in Iwona

I never had any problems using Iwona as a math font, even with much more exotic symbols. I'm a bit surprised this occurs at this point and of course I'd like to know how to fix it.

  • What happens if you just use \|x\| for norm? – Predrag Punosevac May 17 '13 at 19:23
  • @PredragPunosevac Good question. The result is the same unfortunately :/ – Christian May 17 '13 at 19:26
  • 3
    @Christian It's a bug that should be reported. – egreg May 17 '13 at 19:37
  • @egreg Ok, I sent Janusz a mail. – Christian May 17 '13 at 19:58
  • 1
    Two years have gone by without any reply and without the problem being fixed so it's probably safe to say by now that Iwona Math is no longer actively supported. – Christian May 28 '15 at 21:39
15

For very strange reasons, the slot "6B in the font sy-iwona is empty. The \lVert and \rVert commands point to that slot, so you can't see any symbol because it's not there to begin with. The definition of \lVert and \rVert given by amsmath are

\DeclareMathDelimiter{\lVert}
  {\mathopen}{symbols}{"6B}{largesymbols}{"0D}
\DeclareMathDelimiter{\rVert}
  {\mathclose}{symbols}{"6B}{largesymbols}{"0D}

which mean: in normal size take the character living in the symbol font in slot "6B while for bigger sizes take the character living in the largesymbols font in slot "0D. The difference between the two is that the former is given \mathopen type, the latter is \mathclose.

Indeed

$\norm[\big]{x}$

works, because the bigger delimiter is found.

enter image description here

There's not so much to do except taking the symbol from another font, for instance

\documentclass[border=4]{standalone}
\usepackage[math]{iwona}
\usepackage{mathtools}

\DeclareSymbolFont{extrasymbols}{OMS}{cmsy}{m}{n}
\DeclareMathDelimiter{\lVert}
  {\mathopen}{extrasymbols}{"6B}{largesymbols}{"0D}
\DeclareMathDelimiter{\rVert}
  {\mathclose}{extrasymbols}{"6B}{largesymbols}{"0D}

\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\begin{document}
Testing $\norm{x}$.

Testing $\norm[\big]{x}$.
\end{document}

enter image description here

Unfortunately, a compatible candidate would be Kurier, which also lacks the symbol.

A different solution, that doesn't require a substitute font, is to emulate the symbol at the size it's missing.

\documentclass[border=4]{standalone}
\usepackage[math]{iwona}
\usepackage{mathtools}
\usepackage{xparse}

\DeclarePairedDelimiter\xnorm{\lVert}{\rVert}
\NewDocumentCommand{\norm}{som}
 {\IfBooleanTF{#1}
   {\xnorm*{#3}}
   {\IfNoValueTF{#2}
     {\mathopen{|\mkern-.8mu|}#3\mathclose{|\mkern-.8mu|}}
     {\xnorm[#2]{#3}}%
   }
 }


\begin{document}
Testing $\norm{x}$.

Testing $\norm[\big]{x}$.
\end{document}

The \norm symbol does like xnorm unless it has no optional argument, in which case the two bars are produced from the single bar.

enter image description here

If you want a definition that works without doing the hack when the bug is fixed, you can do like this:

\documentclass[border=4]{standalone}
\usepackage[math]{iwona}
\usepackage{mathtools}
\usepackage{xparse}

\makeatletter
\AtBeginDocument{%
  \check@mathfonts
  \iffontchar\textfont2 "6B
    \DeclarePairedDelimiter\norm{\lVert}{\rVert}
  \else
    \DeclarePairedDelimiter\xnorm{\lVert}{\rVert}
    \NewDocumentCommand{\norm}{som}
     {\IfBooleanTF{#1}
       {\xnorm*{#3}}
         {\IfNoValueTF{#2}
           {\mathopen{|\mkern-1mu|}#3\mathclose{|\mkern-1mu|}}
           {\xnorm[#2]{#3}}%
       }%
    }
  \fi
}
\makeatother

\begin{document}
Testing $\norm{x}$.

Testing $\norm[\big]{x}$.

\end{document}

It works with all fonts so long as they don't use bizarre slots for the double vertical bar. It will define \norm in the easier way if the character exists, otherwise it will do the hack.

  • I think .8mu is a tiny bit too wide, 1mu works better for me but other than that, this is an ingenious hack :) – Christian May 17 '13 at 20:16
  • 1
    @Christian Maybe you're right. I added a better hack that will use the correct glyph once the bug is fixed. – egreg May 17 '13 at 20:34
4

EDIT for left/right. While David Carlisle points out that my solution does not work for vertically scaled \left \right syntax, the \stretchleftright{}{}{} syntax of the scalerel package takes care of it.

\documentclass{standalone}
\usepackage[math]{iwona}
\usepackage{mathtools}
\usepackage{scalerel}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\def\lVert{\mid\!\mid}
\def\rVert{\mid\!\mid}
\begin{document}
Testing $\norm{x}$.
Testing $\norm{\frac{x}{y}}$.
Testing $\stretchleftright{\lVert}{\frac{x}{y}}{\rVert}$.
\end{document}

enter image description here

  • That wouldn't work at bigger sizes the \left\right added by the paired delimiter declaration would only apply to one of the bars. – David Carlisle May 17 '13 at 19:33
  • No it needs to be a single character. – David Carlisle May 17 '13 at 19:39
  • Ok, that's one way to solve this … – Christian May 17 '13 at 19:40
  • I didn't know about this scalerel feature. This might come in handy :) – Christian May 17 '13 at 20:05
  • @Christian. Version 1.5 scalerel just got uploaded today...might take a few days to propagate. But it fixes some package conflicts that arose with version 1.4. – Steven B. Segletes May 18 '13 at 0:51

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.