TeX - LaTeX Asked on October 4, 2020
I would like to define a math operator that looks a bit like this, which I mocked up in an image editor from the amsmath
square
symbol:
Sometimes there will be a different letter than lambda inside the box, or an expression like lambda'
, but the box should always be the same size, and always be square – it’s meant to be an inline operator with a symbol drawn on it, not a box around part of a formula.
I don’t mind if I have to manually position the formula inside it, as there will probably only be a few different letters that I’ll use.
It doesn’t have to be based on square
. In fact I think it would look nicer if the baseline was a bit lower, to match +
for example.
Is there a reasonable way to achieve this?
Here's a solution using a framebox
of fixed size. I thought it would look better if the symbol in the square was smaller, in scriptstyle
. I think it looks reasonably good with any lowercase latin or greek letter.
documentclass{article}
usepackage{amsmath}
newcommand{squareop}[1]{%
setlength{fboxsep}{0pt}%
setlength{unitlength}{.7em}%
mathrel{%
raisebox{-1pt}{framebox(1,1){(scriptstyle #1)}}%
}%
}
begin{document}
begin{tabular}{lll}
( x squareop{a} y ) & ( x squareop{b} y ) & ( x squareop{c} y )
( x squareop{d} y ) & ( x squareop{e} y ) & ( x squareop{f} y )
( x squareop{g} y ) & ( x squareop{h} y ) & ( x squareop{i} y )
( x squareop{j} y ) & ( x squareop{k} y ) & ( x squareop{l} y )
( x squareop{m} y ) & ( x squareop{n} y ) & ( x squareop{o} y )
( x squareop{p} y ) & ( x squareop{q} y ) & ( x squareop{r} y )
( x squareop{s} y ) & ( x squareop{t} y ) & ( x squareop{u} y )
( x squareop{v} y ) & ( x squareop{w} y ) & ( x squareop{z} y )
end{tabular}
qquad
begin{tabular}{lll}
( x squareop{alpha} y ) & ( x squareop{beta} y ) & ( x squareop{gamma} y )
( x squareop{delta} y ) & ( x squareop{epsilon} y ) & ( x squareop{zeta} y )
( x squareop{eta} y ) & ( x squareop{theta} y ) & ( x squareop{iota} y )
( x squareop{kappa} y ) & ( x squareop{lambda} y ) & ( x squareop{mu} y )
( x squareop{nu} y ) & ( x squareop{xi} y ) & ( x squareop{pi} y )
( x squareop{rho} y ) & ( x squareop{sigma} y ) & ( x squareop{tau} y )
( x squareop{upsilon} y ) & ( x squareop{phi} y ) & ( x squareop{varphi} y )
( x squareop{chi} y ) & ( x squareop{psi} y ) & ( x squareop{omega} y )
end{tabular}
end{document}
Correct answer by Vincent on October 4, 2020
You may also want the big version.
documentclass{article}
usepackage{amsmath,array,relsize}
makeatletter
DeclareRobustCommand{boxop}[1]{mathbin{mathpalettebox@op{#1}}}
DeclareRobustCommand{bigboxop}[1]{mathop{mathpalettebigbox@op{#1}}slimits@}
newcommand{box@op}[2]{%
begingroup
sboxz@{$m@th#1mkern15mu$}%
dimen@=wdz@
setlength{fboxsep}{0pt}%
makebox[dimen@]{%
framebox[0.9dimen@]{%
vbox to 0.9dimen@{%
vss
hbox{raisebox{depth}{$box@op@style{#1}#2$}}%
vss
}%
}%
}%
endgroup
}
newcommand{box@op@style}[1]{%
ifx#1displaystylescriptstyleelse
ifx#1textstylescriptstyleelse
scriptscriptstylefifim@th
}
newcommand{bigbox@op}[2]{%
begingroup
sboxz@{$m@th#1sum$}%
dimen@=wdz@
vphantom{sum}%
vcenter{%
setlength{fboxsep}{0pt}%
hbox to dimen@{%
hss
framebox[0.9dimen@]{%
vbox to 0.9dimen@{%
vss
hbox{raisebox{depth}{$m@th#1box@op@larger{#1}{#2}$}}%
vss
}%
}%
hss
}%
}%
endgroup
}
newcommand{box@op@larger}[2]{%
ifx#1displaystyle
expandafter@firstoftwo
else
expandafter@secondoftwo
fi
{mathlarger{#2}}{#2}%
}
makeatother
begin{document}
$xboxop{lambda}yboxop{lambda!'}zboxop{varphi}wboxop{beta}u$
$scriptstyle xboxop{lambda}yboxop{lambda!'}z$
$displaystylesum_{k=1}^nbigboxop{lambda}_{k=1}^n x_k$
$bigboxop{lambda}_{k=1}^n x_k$
$scriptstylebigboxop{lambda}_{k=1}^n x_k$
$displaystylesum_{k=1}^nsum_{k=1}^n x_k$
end{document}
Answered by egreg on October 4, 2020
Using youngtab
that I not knew with the symbol inside math operator. It is right to write that the square has the same dimension.
documentclass[a4paper,12pt]{article}
usepackage{amsmath,amssymb}
usepackage{youngtab}
Ylinethick{0.5pt}
begin{document}
$a mathrel{young(lambda)} b$, $A_{mathrel{young(mu)_c^d}}$, $Xsimsum_{i=1}^nx_imathrel{young(diamond)}y_i$.
end{document}
Answered by Sebastiano on October 4, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP