我正在用 LaTeX 写一个数学方程,但想用虚线段表示一些符号。实际上,我想使用\sqcup
由三条线段组成的,并希望每条线段都用虚线代替。有人能告诉我怎么做吗?
答案1
它是TikZ 解决方案。
代码
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{calc}
\newcommand*\Dottedsqcupmaxdots{7}
\newcommand*\Dottedsqcupcircleradius{.7\pgflinewidth}
\newcommand*\DottedSqCupsquarefactor{1.8}
\newcommand*\everyscquphspace{\mspace{1.2mu}} % needs amsmath
\newbox\boxdottedsqcup
\newbox\boxDottedsqcup
\newbox\boxDottedSqcup
\newbox\boxDottedSqCup
\savebox\boxdottedsqcup{\ensuremath{\everyscquphspace}\tikz{\draw[dash pattern=on \pgflinewidth off \pgflinewidth] (0,14.5\pgflinewidth) -- (0,0) -- (12\pgflinewidth,0) -- + (0,14.5\pgflinewidth);}\ensuremath{\everyscquphspace}}
\savebox\boxDottedsqcup{%
\ensuremath{\everyscquphspace}%
\tikz{
\foreach \x in {0,...,\Dottedsqcupmaxdots} {
\fill (0,2*\x*\pgflinewidth) circle (\Dottedsqcupcircleradius);
\ifnum\x<\numexpr\Dottedsqcupmaxdots-1\relax
\fill (2*\x*\pgflinewidth,0) circle (\Dottedsqcupcircleradius);
\fi
\pgfmathparse{2*(\Dottedsqcupmaxdots-1)*\pgflinewidth}
\fill (\pgfmathresult pt,2*\x*\pgflinewidth) circle (\Dottedsqcupcircleradius);
}
}%
\ensuremath{\everyscquphspace}%
}
\savebox\boxDottedSqcup{%
\ensuremath{\everyscquphspace}%
\tikz{
\pgfmathparse{\Dottedsqcupmaxdots-1}
\foreach \x in {0,...,\pgfmathresult} {
\fill (0,2.2*\x*\pgflinewidth) circle (\Dottedsqcupcircleradius);
% \ifnum\x<\numexpr\Dottedsqcupmaxdots-1\relax
\fill (2.2*\x*\pgflinewidth,0) circle (\Dottedsqcupcircleradius);
% \fi
\pgfmathparse{2.2*(\Dottedsqcupmaxdots-1)*\pgflinewidth}
\fill (\pgfmathresult pt,2.2*\x*\pgflinewidth) circle (\Dottedsqcupcircleradius);
}
}%
\ensuremath{\everyscquphspace}%
}
\savebox\boxDottedSqCup{%
\ensuremath{\everyscquphspace}%
\tikz{
\pgfmathparse{\Dottedsqcupmaxdots-1}
\foreach \x in {0,...,\pgfmathresult} {
\fill (0,2.2*\x*\pgflinewidth) ++(135:\Dottedsqcupcircleradius) rectangle +(\DottedSqCupsquarefactor*\Dottedsqcupcircleradius,-\DottedSqCupsquarefactor*\Dottedsqcupcircleradius);
% \ifnum\x<\numexpr\Dottedsqcupmaxdots-1\relax
\fill (2.2*\x*\pgflinewidth,0) ++(135:\Dottedsqcupcircleradius) rectangle +(\DottedSqCupsquarefactor*\Dottedsqcupcircleradius,-\DottedSqCupsquarefactor*\Dottedsqcupcircleradius);
% \fi
\pgfmathparse{2.2*(\Dottedsqcupmaxdots-1)*\pgflinewidth}
\fill (\pgfmathresult pt,2.2*\x*\pgflinewidth) ++(135:\Dottedsqcupcircleradius) rectangle +(\DottedSqCupsquarefactor*\Dottedsqcupcircleradius,-\DottedSqCupsquarefactor*\Dottedsqcupcircleradius);
}
}%
\ensuremath{\everyscquphspace}%
}
\newcommand*{\dottedsqcup}{\mathbin{\usebox\boxdottedsqcup}}
\newcommand*{\Dottedsqcup}{\mathbin{\usebox\boxDottedsqcup}}
\newcommand*{\DottedSqcup}{\mathbin{\usebox\boxDottedSqcup}}
\newcommand*{\DottedSqCup}{\mathbin{\usebox\boxDottedSqCup}}
\begin{document}\noindent
\(1\sqcup2\)\\
\(1\dottedsqcup 2\)\\
\(1\Dottedsqcup 2\)\\
\(1\DottedSqcup 2\)\\
\(1\DottedSqCup 2\)
\end{document}