垂直镜像叠置三角形的通用定义

垂直镜像叠置三角形的通用定义

在本题中,我们尝试将两个未填充的三角形叠放在一起,垂直镜像,作为关系符号。以下是我们迄今为止尝试过的方法:

\documentclass{article}
\pagestyle{empty}
\usepackage{unicode-math}
\usepackage{mathtools}
\setmathfont{XITSMath-Regular.otf}
\usepackage{todonotes}
\newcommand{\hasTypeA}[1]{
  \mathrel{\raisebox{.3ex}{\scalebox{.55}{\(\genfrac{}{}{0pt}{3}{\vartriangle}{\triangledown}\)}}}
}
\newcommand{\hasTypeB}[1]{
  \mathrel{\raisebox{.3ex}{\scalebox{.55}{\(\genfrac{}{}{0pt}{3}{\triangledown}{\vartriangle}\)}}}
}
\begin{document}\noindent
\(\mathit{var}\hasTypeA\mathit{Type}\ {}^{\mathit{var}\hasTypeA\mathit{Type}}\ {}^{{}^{\mathit{var}\hasTypeA\mathit{Type}}}\)
\[\mathit{var}\hasTypeA\mathit{Type}\ {}^{\mathit{var}\hasTypeA\mathit{Type}}\ {}^{{}^{\mathit{var}\hasTypeA\mathit{Type}}}\]
\(\mathit{var}\hasTypeB\mathit{Type}\ {}^{\mathit{var}\hasTypeB\mathit{Type}}\ {}^{{}^{\mathit{var}\hasTypeB\mathit{Type}}}\)
\[\mathit{var}\hasTypeB\mathit{Type}\ {}^{\mathit{var}\hasTypeB\mathit{Type}}\ {}^{{}^{\mathit{var}\hasTypeB\mathit{Type}}}\]
\todo[inline]{%
\(\mathit{var}\hasTypeA\mathit{Type}\ {}^{\mathit{var}\hasTypeA\mathit{Type}}\ {}^{{}^{\mathit{var}\hasTypeA\mathit{Type}}}\)
\[\mathit{var}\hasTypeA\mathit{Type}\ {}^{\mathit{var}\hasTypeA\mathit{Type}}\ {}^{{}^{\mathit{var}\hasTypeA\mathit{Type}}}\]
\(\mathit{var}\hasTypeB\mathit{Type}\ {}^{\mathit{var}\hasTypeB\mathit{Type}}\ {}^{{}^{\mathit{var}\hasTypeB\mathit{Type}}}\)
\[\mathit{var}\hasTypeB\mathit{Type}\ {}^{\mathit{var}\hasTypeB\mathit{Type}}\ {}^{{}^{\mathit{var}\hasTypeB\mathit{Type}}}\]
}
\end{document}

使用xelatex收益进行编译

编辑后

如您所见,这个结果存在几个问题。

首先,这两个三角形相距较远;如果它们至少在 中更靠近一点,\hasTypeA也许在 中更靠近一点会更好\hasTypeB(但不要像在 ⧖ 或 ⟠ 中那么靠近)。其次,它们在 (下) 下标和 (上) 上标中不缩放。第三,该解决方案仅适用于xelatex,而对于lualatex则变得很难看,无论如何我们都需要对 做一些不同的事情pdflatex

虽然我可能能够提供一个巨大的字体相关定义\mathpalette,包括\ifxetex、、、\ifluatexstmaryrd(如果需要)tikz,但它既不美观也不简单。有没有既通用又简单的东西?或者到目前为止,有人在他们的论文中完成了这项巨大的肮脏工作,并愿意分享他们的尝试?

答案1

我不确定这应该是\mathrel。无论如何,对于脚本样式,我选择使用 添加一些侧边距\nonscript\mkern-6mu\mkern6mu(仅在和\nonscript中有效,因此它将抵消字距)。\displaystyle\textstyle

\documentclass{article}

\usepackage{todonotes}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{unicode-math}

\setmathfont{XITSMath-Regular.otf}

\makeatletter
\DeclareRobustCommand{\hasTypeA}{%
  \mathrel{%
    \nonscript\mkern-2mu\mkern2mu
    \mathpalette\hasType@AB{\vartriangle\triangledown}%
    \nonscript\mkern-2mu\mkern2mu
  }%
}
\DeclareRobustCommand{\hasTypeB}{%
  \mathrel{%
    \nonscript\mkern-2mu\mkern2mu
    \mathpalette\hasType@AB{\triangledown\vartriangle}%
    \nonscript\mkern-2mu\mkern2mu
  }%
}
\newcommand{\hasType@AB}[2]{\hasType@@AB#1#2}
\newcommand{\hasType@@AB}[3]{%
  \begingroup
  \sbox\z@{$#1x$}%
  \resizebox{!}{\ht\z@}{%
    \vbox{%
      \ialign{%
        ##\cr
        $\m@th#1#2$\cr
        \noalign{\nointerlineskip\vskip0.4pt}%
        $\m@th#1#3$\cr
      }%
    }%
  }%
  \endgroup
}
\makeatother


\begin{document}

\(
  \mathit{var}\hasTypeA\mathit{Type}
  \scriptstyle\mathit{var}\hasTypeA\mathit{Type}
  \scriptscriptstyle\mathit{var}\hasTypeA\mathit{Type}
\)

\(
  \mathit{var}\hasTypeB\mathit{Type}
  \scriptstyle\mathit{var}\hasTypeB\mathit{Type}
  \scriptscriptstyle\mathit{var}\hasTypeB\mathit{Type}
\)

\(\displaystyle
  \mathit{var}\hasTypeA\mathit{Type}
  \scriptstyle\mathit{var}\hasTypeA\mathit{Type}
  \scriptscriptstyle\mathit{var}\hasTypeA\mathit{Type}
\)

\(\displaystyle
  \mathit{var}\hasTypeB\mathit{Type}
  \scriptstyle\mathit{var}\hasTypeB\mathit{Type}
  \scriptscriptstyle\mathit{var}\hasTypeB\mathit{Type}
\)

\todo[inline]{$\hasTypeA$}

\end{document}

在此处输入图片描述

答案2

如果您想改变间隙,请编辑4pt。如果您想改变整体高度,请将更改{X}为具有不同垂直足迹的内容(可能是以测量值\rule表示的ex

\documentclass{article}
\usepackage{scalerel,stackengine,tikz}
\usetikzlibrary{shapes.geometric}
\tikzset{
    uptri/.style={
        draw,
        ultra thick,
        regular polygon,
        regular polygon sides=3,
    }
}
\tikzset{
    dntri/.style={
        draw,
        shape border rotate=180,
        ultra thick,
        regular polygon,
        regular polygon sides=3,
    }
}
\savestack\uptri{\tikz{\node[uptri]{}}}
\savestack\dntri{\tikz{\node[dntri]{}}}
\DeclareRobustCommand\outtri{\mathrel{\scalerel*{%
  \stackengine{4pt}{\dntri}{\uptri}{O}{c}{F}{F}{S}}{X}}}
\DeclareRobustCommand\intri{\mathrel{\scalerel*{%
  \stackengine{4pt}{\uptri}{\dntri}{O}{c}{F}{F}{S}}{X}}}
\begin{document}
$x \outtri Type\qquad x \intri Type$

$\scriptstyle x \outtri Type\qquad x \intri Type$

$\scriptscriptstyle x \outtri Type\qquad x \intri Type$
\end{document}

在此处输入图片描述

例如,将总高度重新定义为占地面积,x而不是X,方法是

\DeclareRobustCommand\outtri{\mathrel{\scalerel*{%
  \stackengine{4pt}{\dntri}{\uptri}{O}{c}{F}{F}{S}}{x}}}
\DeclareRobustCommand\intri{\mathrel{\scalerel*{%
  \stackengine{4pt}{\uptri}{\dntri}{O}{c}{F}{F}{S}}{x}}}

从而改变结果:

在此处输入图片描述

相关内容