# How to typeset the house of an algebraic number?

I would like to reproduce the following text

but I couldn't find the house symbol neither through Detexify nor by looking through the Comprehensive LaTeX Symbol List. I also tried combining vertical bars and overline like

\left\lvert\overline{ \alpha }\rvert\right
\overline{\left\lvert \alpha \rvert\right}


to less than desirable results.

-
I had never seen this notation, since now. –  Sigur Apr 6 '14 at 12:33
Welcome to TeX.SX! –  Heiko Oberdiek Apr 6 '14 at 12:45
@Sigur: it is the maximum absolute value of the conjugates of \alpha. –  A.P. Apr 6 '14 at 12:52
@Sigur -- i've found a use of this "symbol" from 1985: math of comp, 45:171, pp.243 ff., by david boyd. it's referred to there as "maximum modulus", and it isn't in unicode. as soon as i can get my workstation to launch my x-windows so that i can research my unicode contact info, i'll be submitting this for addition to the 2D00 "diacritics for use with math symbols" block. (the name "house" appears to be rather newer; i have found a few other references using this construction, but "house" appears only post-2000.) –  barbara beeton Apr 6 '14 at 14:08
@Sigur -- i've heard back from my unicode contacts that a "cover" corresponding to this was requested earlier in the context of roman numerals, and rejected -- use markup, they say. mathml has the concept "menclose" that would include this shape, but it isn't, in fact, covered in the list that otherwise looks like a pretty thorough documentation of the element. i'll take this up with david carlisle when i get back to the office at the end of april. (off to germany to enjoy dante's 25th anniversary celebration, and then some rustication.) –  barbara beeton Apr 7 '14 at 21:53

There are some issues to consider:

## Line width

• The standard line width in TeX is 0.4pt, it is hardcoded in TeX as 26214sp.

• \overline uses a different line width. It is taken from font parameter 8 of math font family 3 in TeX.

The standard math fonts (Computer Modern) are using 0.39998pt in all font sizes. But it is scalable in other fonts, e.g. package mathptmx with 10pt as class option:

• 0.3999pt in \textfont (\textstyle/\displaystyle)
• 0.29591pt in \scriptfont (\scriptstyle)
• 0.23993pt in \scriptscriptfont (\scriptscriptstyle)

## \overline

• TeX constructs a \overline{...} the following way with θ as line width (pseudo code):

\vbox{
\kern θ
\hrule height θ
\kern 3*θ
\hbox{$...$}
}


Especially there is white space above the rule. This is useful, if the overlined symbol is put in the denominator of a fraction, for instance.

• TeX uses cramped math style for the math expression of \overline. This means, the superscripts are moved down a little, for a better visual appearance.

Thus \overline looks like a good choice for the "house" symbols. However, the vertical lines should use the same line width as used by \overline.

## Spacings

• TeX inserts 3 * θ (θ = line width of \overline) between the formula and the line in \overline. This cannot be easily changed without loosing cramped style. (AFAIK only LuaTeX can set cramped style explicitly.)

• Extra space is added above the line in \overline, see above.

• Usually symbols have side bearings, space at the left and right side of the symbol. The exact amount is usually not available in TeX. The example uses 2 * θ as horizontal space between the vertical lines and the formula. Also a horizontal space 1.5 * θ is put outside the vertical lines. Some kind of side bearings of the new symbol to avoid touching of housed math expressions.

• Since the OP wants longer lines (see comment), the example adds 2 * θ as additional depth. (3 * θ seems too large, because there is not a underline that needs some distance from the formula.)

The full example also takes into account the different math styles, thus macro \house respects the current math sizes.

\documentclass{article}
\usepackage{mathptmx}

\makeatletter
\newcommand*{\house}[1]{%
\mathord{%
\mathpalette\@house{#1}%
}%
}
\newcommand*{\@house}[2]{%
% #1: math style
% #2: expression that gets the "house"
% get the line width of \overline' in the current math font size
\dimen@=\fontdimen8 %
\ifx#1\scriptscriptstyle\scriptscriptfont
\else\ifx#1\scriptstyle\scriptfont
\else\textfont\fi\fi
3 %
\sbox0{%
$#1% \vrule width\dimen@\relax \overline{% \kern2\dimen@ \begingroup % to keep changes of \dimen@ in #2 local #2% \endgroup \kern2\dimen@ }% \vrule width\dimen@\relax \mathsurround=1.5\dimen@ % outside margin$%
}%
% TeX adds an empty space above \overline', it needs to be
% removed to get the correct height for the \vrule's
\ht0=\dimexpr\ht0-\dimen@\relax
\dp0=\dimexpr\dp0+2\dimen@\relax
\vbox{%
\kern\dimen@ % reinsert previously removed space
\copy0 %
}%
}

\begin{document}
$\textstyle % same size as \displaystyle \house{\alpha + \beta} \stackrel{\mbox{\tiny T}}{=} \house{\alpha} + \house{\beta}^n$
$\scriptstyle \house{\alpha + \beta} \stackrel{\mbox{\tiny S}}{=} \house{\alpha} + \house{\beta}^n$
$\scriptscriptstyle \house{\alpha + \beta} \stackrel{\mbox{\tiny SS}}{=} \house{\alpha} + \house{\beta}^n$
$\def\x{\frac{\house{\alpha + \beta}}{\house{\alpha} + \house{\beta}}} \x, \frac{\x}{\x}$
$\underbrace{\overline{\alpha^2}, \house{\alpha^2}}_{\mbox{\tiny cramped}} \ne \overline{\mbox{\alpha^2}}, \house{\mbox{\alpha^2}}$
\end{document}


-
Awesome! * epic music playing * –  Henri Menke Apr 6 '14 at 14:45
This is a great answer, thanks! One last question: would it be possible to add a little space to the (outer) sides of the symbol, so that e.g. \house{\alpha}\house{\beta} or \house{\alpha}^n do not look too cramped? –  A.P. Apr 7 '14 at 13:18
There is already some space (0.5 line width), I have increased it to 1.5 line width and added exponents in the test file. –  Heiko Oberdiek Apr 7 '14 at 13:34
Lovely! Does the space come from \mathsurround=.5\dimen@? –  A.P. Apr 7 '14 at 13:52

Here is a plain TeX solution. The downside is, that \everymath is executed inside the "house". If you want every house to have the same height and depth, add a strut or a phantom inside it.

\nopagenumbers% for cropping
\def\house#1{{%
\setbox0=\hbox{$#1$}
\vrule height \dimexpr\ht0+1.4pt width .4pt depth \dp0\relax
\vrule height \dimexpr\ht0+1.4pt width \dimexpr\wd0+2pt depth \dimexpr-\ht0-1pt\relax
\llap{$#1$\kern1pt}
\vrule height \dimexpr\ht0+1.4pt width .4pt depth \dp0\relax
}}

$\house{\alpha + \beta} \leq \house{\alpha} + \house{\beta}$
\medskip
$\house{\strut\alpha + \beta} \leq \house{\strut\alpha} + \house{\strut\beta}$
\bye


Bonus question: Is there a plain TeX dimen, which holds the default linewidth of .4pt? I only know about \p@=1pt and \z@=0pt.

-
The default value of 0.4pt for \hrule or \vrule is hardcoded in TeX as 26214sp (= 0.4pt). The line width for \overline depends on the fonts and are available in the font parameter \fontdimen8\<math size>font3 , e.g. \fontdimen8\scriptfont3  in math style \scriptstyle. The CM fonts are using 0.39998pt in all sizes (text, script, scriptscript. The line width of \overline in fonts by package mathptmx gets smaller with smaller sizes (0.3999pt/\textstyle, 0.29591pt/\scriptstyle, and 0.23993pt/\scriptscriptstyle; in all cases with 10pt as class option). –  Heiko Oberdiek Apr 6 '14 at 13:11
@HeikoOberdiek Thank you very much for that clarification! –  Henri Menke Apr 6 '14 at 13:15
Is there a way to increase the length of the vertical bars, so that they are slightly longer than the argument? –  A.P. Apr 6 '14 at 13:38
@A.P. Well, the vertical bar is longer than the argument. Could you please elaborate? –  Henri Menke Apr 6 '14 at 14:01
@A.P. Replace \dp0 with \dimexpr\dp0+.5pt. Of course you can adjust the .5pt to your liking. –  Henri Menke Apr 6 '14 at 15:07

With the horizontal bar slightly protruding:

\documentclass[a4paper,12pt]{article}
\usepackage{array}

\newcommand\house[1]{%
\begingroup\setlength\arraycolsep{0pt}
\begin{array}[t]{@{\mkern1mu}c@{}|c|@{}c@{\mkern1mu}}
\firsthline
&\;#1\;{}&
\end{array}
\endgroup
}

\begin{document}

$\house{\alpha + \beta} \leq \house{\alpha} + \house{\beta}$

\end{document}


The protrusion can be controlled by increasing the amount given with \mkern; this is with \mkern2mu

As barbara beeton notes in a comment, the bar shouldn't protrude; for this just remove the \mkern instruction:

\newcommand\house[1]{%
\begingroup\setlength\arraycolsep{0pt}
\begin{array}[t]{@{}c@{}|c|@{}c@{}}
\firsthline
&\;#1\;{}&
\end{array}
\endgroup
}


-
nope, don't want the horizontal bar protruding. here's a reference "in the literature": david w. boyd, "the maximal modulus of an algebraic integer", math. of comp., 45:171 (1985), pp.243-249. that one wasn't done with tex; it was most likely composed with the sti system, and clearly was "patched together" (the top edge of the box doesn't always meet the verticals). but it's the earliest reference i've found that's readily accessible. –  barbara beeton Apr 6 '14 at 15:57

An implementation with tikz, shamefully adapted from this answer

\documentclass{standalone}
\usepackage{tikz}

\usetikzlibrary{calc}
\newcommand{\house}[1]{%
\tikz[baseline]{\node[anchor=base,inner sep=0.3ex](mynode){\ensuremath{#1}};
\draw(mynode.south west)--(mynode.north west)--(mynode.north east)--(mynode.south east);
\path[use as bounding box]($(mynode.south west)+(-0.3ex,-0.3ex)$)rectangle($(mynode.north east)+(0.3ex,0.3ex)$);}
}

\begin{document}
$\house{\alpha+\beta}\leq\house{\alpha}+\house{\beta}$
\end{document}


-

Never seen it either. However, here is a way of doing things: put everything into an array, with hhline to have a clean connection of vertical and horizontal lines. I define a normal and a bold version I don'tknow how to declare it, so as to have only one command for both versions):

\documentclass[a4paper,12pt]{article}

\usepackage{mathtools}
\usepackage{hhline, bm}
\newcommand\house[1]{\mkern2mu\begin{array}{|@{\:}c@{\:}|}\hhline{|-|}#1\end{array}\mkern1mu}
\newcommand\boldhouse[1]{\setlength{\arrayrulewidth}{0.6pt}\mathversion{bold}%
\mkern2mu\begin{array}{|@{\:}c@{\: }|}\hhline{|-|}#1\end{array}\mkern1mu}%

\begin{document}

$\house{α + β} \leq \house{α} + \house{β}$\\

$\mathversion{bold} \boldhouse{α + β} \leq \boldhouse{α} + \boldhouse{β}$

\end{document}


The result, in my opinion, is better than the OP's image (same height for all symbols):

There should remain to define a bold version.

-
\newcommand{\house}[1]{
\setbox0=\hbox{$#1$}
\rule{.4pt}{\dimexpr\ht0 + 1.6pt}
\overline{\mkern+1mu
#1
\mkern+1mu}
\rule{.4pt}{\dimexpr\ht0 + 1.6pt}
}
`
-