3

How to properly absolute values and norms in ConTeXt? I currently use:

\m{|x|\leq|y|}

But the height does not adapt to the content (same thing for \mid).

  • 1
    I don't know Context, but take a look at the mathtools package and its \DeclarePairedDelimiter command (§ 3.6, Paired Delimiters, pp. 25-30 of the documentation). – Bernard Feb 20 at 21:42
  • 1
    @Bernard I don't think you can use latex packages in context – daleif Feb 20 at 21:44
  • @daleif: I thought some were compatible. Am I entirely wrong? – Bernard Feb 20 at 21:46
  • Actually, it depends on the command used by the dev. If only plain tex is used there is no compatibility issue (this is almost the case for tikz) but AFAIK mathtools is not compatible. – Blincer Feb 20 at 21:50
  • @Bernard not sure, never used context, there are some low level packages that also support context (like tikz). Not sure about amsmath – daleif Feb 20 at 21:51
4

You could use the \fenced command. For example:

\starttext

\startformula
  \fenced[doublebar]{\int \psi(r) dr} = 1
\stopformula

\stoptext

enter image description here

You can find a list of defined fences in math-fen.mkiv.

If you don't want to use the \fenced macro, you can also use the fences directly with \L and \R prefix. These will also scale automatically and have to matched, just like \left and \right.

\starttext

\startformula
  \Ldoublebar \int \psi(r) dr \Rdoublebar = 1
\stopformula

\stoptext

The output is the same.

3

In addition to the existing answers, I would suggest to add these as new commands, with

\definemathfence[abs][left="007C,right="007C,command=yes]
\definemathfence[norm][left="2016,right="2016,command=yes]

Complete example below:

\definemathfence[abs][left="007C,right="007C,command=yes]
\definemathfence[norm][left="2016,right="2016,command=yes]
\starttext
\startTEXpage[offset=4mm]
Now we can type
\startformula
\abs{x}\geq\abs{\frac{y}{z}},\quad \norm{x}\geq\norm{\frac{y}{z}}
\stopformula
And if you think the sizes get wrong, you can adjust them like this:
\startformula
\abs{x}\geq\abs[size=2]{\frac{y}{z}},\quad \norm{x}\geq\norm[size=2]{\frac{y}{z}}
\stopformula
\stopTEXpage
\stoptext

This is a picture showing the output of the code above

  • You don’t have to set the left and right values when you inherit the symbols from bar and doublebar with \definemathfence [abs] [bar] [command=yes] and \definemathfence [norm] [doublebar] [command=yes]. – Wolfgang Schuster Feb 21 at 16:47
  • Thanks for commenting on this @WolfgangSchuster, I did not know! (At the point where I needed them for myself I just copied them from the source). I can add as a comment that I have asked for support for the possibility to write \abs[size=Big]{\frac{y}{z}} (syntax choice inspired from mathtools) to have \Bigl| and \Bigr. I hope it will be added after the TeXLive freeze. – mickep Feb 21 at 20:43
2

\left| and \right| scale automatically:

\m{\left| x \right| \leq \left| y^2 \right|}

enter image description here

  • Keep in mind that unlike in LaTeX, \| is only a single vertical bar. To get the double vertical bar use \Vert. – Henri Menke Feb 20 at 22:45

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.