3

I'm looking to denote the area of a triangle by encasing a suitably-chosen expression in a pair of tall colored vertical lines. The idea is somewhat similar, but not identical, to the pair of vertical bars that are frequently used to denote the determinant of a matrix.

I suppose I could just write $\text{area}(\triangle ABC)=\lvert \det(M) \rvert$. For sure, though, I'd rather use a color other than black for the tall vertical lines. Something like the following:

enter image description here

\documentclass[12pt]{article}
\usepackage{mathtools}
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\begin{document} 
\[
\text{area}(\triangle ABC)= 
%%  some code here ...
\frac{1}{2} \begin{vmatrix}
\ldots & \ldots & \ldots  \\ 
\ldots & \ldots & \ldots \\ 
\ldots & \ldots & \ldots  \\ 
\ldots & \ldots & \ldots  
\end{vmatrix}   
%%  some more code here ...
\]
\end{document}
  • 1
    In my opinion, it would be better here to keep the coloured vertical rules for the absolute value and inside write \det\begin{pmatrix} ... \end{pmatrix}. Graphically, it would look less ‘repetitive’. – Bernard Apr 8 at 19:42
  • @Bernard I agree with you, too. In fact, it says in the school books like your commentary. It's just that students are writing less and less and I want everything now. So I thought about class before the suspension because of the coronavirus to eliminate \det. My previous colleagues have always learned to write vertical bars and trouble if I write something other than that. :-) Just for color is important to understand the differences between determinant and absolute value. – Sebastiano Apr 8 at 19:47
  • I'm not sure to understand the syntax you want. Do you want a redefinition of \lvert? – F. Pantigny Apr 8 at 19:55
  • 1
    Unrelated: as always \text is wrong here either use operatorname or define \area properly – daleif Apr 8 at 20:33
  • 1
    I'm not sure what should be the conveyed meaning. Note that denoting the determinant just with vertical bars is very old-fashioned. – egreg Apr 8 at 20:55
6

I propose these three solutions, the second one with the absolute value sign slightly longer than the vertical lines of the determinant, the last one with the \det command, so that you can choose:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage{mathtools}
\usepackage{array}
\usepackage[svgnames]{xcolor}

\begin{document}

\[\text{area}(\triangle ABC)=\begin{array}{@{\color{Coral}\vrule width 0.6pt\,}c@{\,\color{Coral}\vrule width 0.6pt}}\begin{vmatrix}
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots
\end{vmatrix} \end{array}\]

\[\text{area}(\triangle ABC)={\color{Coral}\begin{vmatrix}{\color{black}\begin{vmatrix}
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots
\end{vmatrix}^{\mathstrut}_{\vphantom{j}}} \end{vmatrix} } \]

\[\text{area}(\triangle ABC)=\begin{array}{@{\color{Coral}\vrule width 0.6pt\mkern 3mu}c@{\color{Coral}\vrule width 0.6pt}}{\det}\mkern-6mu\begin{pmatrix}
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots \\
\ldots & \ldots & \ldots
\end{pmatrix} \end{array}\]

\end{document} 

enter image description here

| improve this answer | |
  • 1
    "Coral" -- ooh la la! :-) +1 – Mico Apr 8 at 20:22
  • 1
    ooh la la! ooh la la! ooh la la! ooh la la! ooh la la! +1 – Sebastiano Apr 8 at 20:36
  • Now who do I give the green tick now? I don't give it to anyone when all the answers are good. Excuse me. – Sebastiano Apr 8 at 20:40
  • 1
    For all answer my compliments and +1. :-) – Sebastiano Apr 8 at 20:48
  • Unfortunately, the colour palette in xcolor does not comprise Carpaccio red, nor Veronese – nor even ‘Cuisse de Nymphe émue’ ;o) – Bernard Apr 8 at 20:54
4

Something like this?

enter image description here

\documentclass[12pt]{article}
\usepackage{mathtools}
\DeclareMathOperator{\area}{area}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[dvipsnames]{xcolor}
\newcommand\orangebars[1]{%
  \begingroup \colorlet{current}{.} \color{orange} \left\vert 
  \begingroup \color{current} #1^{\mathstrut} \kern-\scriptspace \endgroup 
  \right\vert \endgroup
}

\begin{document} 
\[
  \area(\triangle ABC) =
  \orangebars{%
     \begin{vmatrix}
     \dots & \dots & \dots \\ 
     \dots & \dots & \dots \\ 
     \dots & \dots & \dots 
  \end{vmatrix}}
\]
\end{document}

Addendum: Changing orange to RedOrange and #1^{\mathstrut} to #1^{\strut} generates the following output:

enter image description here

Just in case you find it difficult to decide on a color somewhere between orange and red, here they are along with three intermediate shades: Coral, Tomato, and OrangeRed (need to load the xcolor package with the option svgnames). :-)

enter image description here

\documentclass{article}
\usepackage[svgnames]{xcolor}
\newcommand\myrule{\rule{2em}{4em}}
\newcommand\manyhues{\color{orange}\myrule\color{Coral}\myrule%
  \color{Tomato}\myrule\color{OrangeRed}\myrule\color{red}\myrule}
\begin{document} 
\manyhues
\end{document}
| improve this answer | |
  • 1
    Is it my impression but the orange colour has faded and is thinner? :-) Is there a toner deficiency? :-))))) Can you make it a little longer leaving this code? – Sebastiano Apr 8 at 20:07
  • 1
    @Sebastiano - Does the color scheme in the addendum I just posted pass muster? :-) – Mico Apr 8 at 20:21
  • 1
    Now who do I give the green tick now? I don't give it to anyone when all the answers are good. Excuse me. – Sebastiano Apr 8 at 20:40
  • 1
    For all answer my compliments and +1. :-) – Sebastiano Apr 8 at 20:48
  • 1
    You could add \colorlet{current}{.} before \color{orange}, and then use \color{current} instead of \color{black}. – egreg Apr 8 at 20:56
2

A solution:

\documentclass[12pt]{article}
\usepackage{mathtools}
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyph

\usepackage{xparse}
\usepackage{color}

\ExplSyntaxOn
\NewDocumentCommand { \BigAbs }{ m }
  {  
    \hbox_set:Nn \l_tmpa_box { $ #1 $ }
    \dim_set:Nn \l_tmpa_dim { \box_ht:N \l_tmpa_box + 3 mm }
    \dim_set:Nn \l_tmpb_dim { \box_dp:N \l_tmpa_box + 3 mm }
    \mathopen{
    \color { red }
    \vrule height \l_tmpa_dim depth \l_tmpb_dim width 1 pt } 
    \; \box_use:N \l_tmpa_box \; 
    \mathclose{
    \color { red }
    \vrule height \l_tmpa_dim depth \l_tmpb_dim width 1 pt }
  }
\ExplSyntaxOff

\begin{document} 
\[\text{area}(\triangle ABC)=
\BigAbs{\begin{vmatrix}
\ldots & \ldots & \ldots  \\ 
\ldots & \ldots & \ldots \\ 
\ldots & \ldots & \ldots  \\ 
\ldots & \ldots & \ldots  
\end{vmatrix}}\]
\end{document}

enter image description here

| improve this answer | |
  • Now who do I give the green tick now? I don't give it to anyone when all the answers are good. Excuse me. – Sebastiano Apr 8 at 20:40
  • For all answer my compliments and +1. :-) – Sebastiano Apr 8 at 20:48

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.