答案1
这里,我引入了 ,\pigpenXXXX
其中XXXX
是 和 的某种组合0
,1
表示左侧、顶部、右侧、底部的笔画(即从左侧开始顺时针方向)。笔画长度和宽度分别由\rlln
和定义\rlwd
。符号被定义为位于基线上。
当然,人们可以定义诸如\def\ppA{\pigpen0011}
等等的字母。
经过编辑以使其适合在数学模式下使用,尽管它也可以在文本模式下运行。
\documentclass{article}
\usepackage{stackengine}
\newlength\rlln
\newlength\rlwd
\newlength\brlwd
\newlength\trlwd
\newlength\lrlwd
\newlength\rrlwd
\rlwd=.5pt
\rlln=5pt
\def\bstr{\rule{\rlln}{\brlwd}\rule{0pt}{\rlwd}}
\def\tstr{\rule{\rlln}{\trlwd}\rule{0pt}{\rlwd}}
\def\lstr{\ooalign{\rule{\lrlwd}{\rlln}\cr\rule{\rlwd}{0pt}}}
\def\rstr{\ooalign{\rule{\rrlwd}{\rlln}\cr\rule{\rlwd}{0pt}}}
\def\gap{\rule{\dimexpr\rlln-2\rlwd}{0pt}}
\def\pigpen#1#2#3#4{\kern1pt% FOUR ARGUMENTS ARE LEFT, TOP, RIGHT, BOTTOM STROKES
\brlwd=#4\rlwd\relax%
\trlwd=#2\rlwd\relax%
\lrlwd=#1\rlwd\relax%
\rrlwd=#3\rlwd\relax%
\stackengine{\dimexpr\rlln-\rlwd}{%
\stackengine{0pt}{\bstr}{\lstr\gap\rstr}{O}{c}{F}{F}{L}%
}{\tstr}{O}{c}{F}{F}{L}\kern1pt%
}
\begin{document}
$x\pigpen0011 \pigpen1011 \pigpen1001 \pigpen0111
\pigpen1111 \pigpen1101 \pigpen0110 \pigpen1110
\pigpen1100 \pigpen1010 \pigpen0101 y$
\end{document}
更新:
OP 要求一个带有圆形端盖的版本。为此,我使用我的自定义样式文件roundrule.sty
,在只在这个答案的最后:
然后,我修改了上述答案,使用舍入规则而不是规则。我可能需要更新roundrule.sty
,因为我发现如果规则尺寸之一为 0pt,它仍会输出一条细线。为了解决此答案的这个问题,我对舍入规则尺寸进行了检查。
\documentclass{article}
\usepackage{stackengine,roundrule}
\newlength\rlln
\newlength\rlwd
\newlength\brlwd
\newlength\trlwd
\newlength\lrlwd
\newlength\rrlwd
\newcommand\rrule[2]{\ifdim#1>0pt\relax\ifdim#2>0pt\relax\roundrule{#1}{#2}\else\fi\else\fi}
\rlwd=.5pt
\rlln=5pt
\def\bstr{\rrule{\rlln}{\brlwd}\rule{0pt}{\rlwd}}
\def\tstr{\rrule{\rlln}{\trlwd}\rule{0pt}{\rlwd}}
\def\lstr{\ooalign{\rrule{\lrlwd}{\rlln}\cr\rule{\rlwd}{0pt}}}
\def\rstr{\ooalign{\rrule{\rrlwd}{\rlln}\cr\rule{\rlwd}{0pt}}}
\def\gap{\rule{\dimexpr\rlln-2\rlwd}{0pt}}
\def\pigpen#1#2#3#4{\kern1pt% FOUR ARGUMENTS ARE LEFT, TOP, RIGHT, BOTTOM STROKES
\brlwd=#4\rlwd\relax%
\trlwd=#2\rlwd\relax%
\lrlwd=#1\rlwd\relax%
\rrlwd=#3\rlwd\relax%
\stackengine{\dimexpr\rlln-\rlwd}{%
\stackengine{0pt}{\bstr}{\lstr\gap\rstr}{O}{c}{F}{F}{L}%
}{\tstr}{O}{c}{F}{F}{L}\kern1pt%
}
\begin{document}
$x\pigpen0011 \pigpen1011 \pigpen1001 \pigpen0111
\pigpen1111 \pigpen1101 \pigpen0110 \pigpen1110
\pigpen1100 \pigpen1010 \pigpen0101 y$
\end{document}
答案2
您可以使用pict2e
。我从中获取了参数pigpen.mf
。
\documentclass{article}
\usepackage{pigpen,pict2e}
\DeclareRobustCommand{\pigpenver}{%
\begingroup\pigpenfont
\setlength{\unitlength}{1em}%
\begin{picture}(1,1)
\linethickness{0.09\unitlength}
\roundcap
\polyline(0.16667,0.16667)(0.16667,0.83333)
\polyline(0.83333,0.16667)(0.83333,0.83333)
\end{picture}%
\endgroup
}
\DeclareRobustCommand{\pigpenhor}{%
\begingroup\pigpenfont
\setlength{\unitlength}{1em}%
\begin{picture}(1,1)
\roundcap
\linethickness{0.09\unitlength}
\polyline(0.16667,0.16667)(0.83333,0.16667)
\polyline(0.16667,0.83333)(0.83333,0.83333)
\end{picture}%
\endgroup
}
\begin{document}
X{\pigpenfont E}X\pigpenhor\pigpenver X
{\pigpenfont E}
\pigpenhor{\pigpenfont BC}
\pigpenver{\pigpenfont BC}
\end{document}
可能更好的界面:
\documentclass{article}
\usepackage{pigpen,pict2e,xparse}
\NewDocumentCommand{\pigpenver}{}{%
\begingroup\pigpenfont
\setlength{\unitlength}{1em}%
\begin{picture}(1,1)
\linethickness{0.09\unitlength}
\roundcap
\polyline(0.16667,0.16667)(0.16667,0.83333)
\polyline(0.83333,0.16667)(0.83333,0.83333)
\end{picture}%
\endgroup
}
\NewDocumentCommand{\pigpenhor}{}{%
\begingroup\pigpenfont
\setlength{\unitlength}{1em}%
\begin{picture}(1,1)
\roundcap
\linethickness{0.09\unitlength}
\polyline(0.16667,0.16667)(0.83333,0.16667)
\polyline(0.16667,0.83333)(0.83333,0.83333)
\end{picture}%
\endgroup
}
\ExplSyntaxOn
\NewDocumentCommand{\pp}{m}
{
\group_begin:
\pigpenfont
\tl_map_inline:nn { #1 }
{
\str_case:nnF { ##1 }
{
{h}{\pigpenhor}
{v}{\pigpenver}
}
{##1}
}
\group_end:
}
\ExplSyntaxOff
\begin{document}
\pp{ABCDEFGHIJKLMNOPQRSTUVWXYZhv}
\pp{hLUCASv}
\verb|\pp{h}| $\to$ \pp{h}
\verb|\pp{v}| $\to$ \pp{v}
\end{document}
只是为了显示结果符合预期(可能达到一些像素),这是我从
\pp{E}\llap{\color{red}\pp{h}}
\pp{h}\llap{\color{red}\pp{E}}
如果您需要符号位于基线(字体设计师决定将它们凸起),请将\pp
最后一段代码中的定义更改为
\NewDocumentCommand{\pp}{m}
{
\group_begin:
\pigpenfont
\raisebox{-0.16667em}
{
\tl_map_inline:nn { #1 }
{
\str_case:nnF { ##1 }
{
{h}{\pigpenhor}
{v}{\pigpenver}
}
{##1}
}
}
\group_end:
}
所以输入
ABC\pp{hLUCASv}DEF
会产生
您还可以为符号定义不同的语法;我使用的顺序是“右下左上”,这rb
意味着“右下”已填充,“左上”为空。这样,您就不需要记住给定组合对应的字母。
\documentclass{article}
\usepackage{pigpen,pict2e,xparse}
\NewDocumentCommand{\pigpenver}{}{%
\begingroup\pigpenfont
\setlength{\unitlength}{1em}%
\begin{picture}(1,1)
\linethickness{0.09\unitlength}
\roundcap
\polyline(0.16667,0.16667)(0.16667,0.83333)
\polyline(0.83333,0.16667)(0.83333,0.83333)
\end{picture}%
\endgroup
}
\NewDocumentCommand{\pigpenhor}{}{%
\begingroup\pigpenfont
\setlength{\unitlength}{1em}%
\begin{picture}(1,1)
\roundcap
\linethickness{0.09\unitlength}
\polyline(0.16667,0.16667)(0.83333,0.16667)
\polyline(0.16667,0.83333)(0.83333,0.83333)
\end{picture}%
\endgroup
}
\ExplSyntaxOn
\NewDocumentCommand{\pp}{m}
{% 'l b r t' is the order
\group_begin:
\pigpenfont
\raisebox{-0.16667em}
{
\clist_map_inline:nn { #1 }
{
\str_case:nn { ##1 }
{
{bt}{\pigpenhor}
{lr}{\pigpenver}
{br}{A}
{lbr}{B}
{lb}{C}
{brt}{D}
{lbrt}{E}
{lbt}{F}
{rt}{G}
{lrt}{H}
{lt}{I}
}
}
}
\group_end:
}
\ExplSyntaxOff
\begin{document}
ABC\pp{lr,br,lrt,lt,bt}DEF
\end{document}
答案3
如果您不介意尖锐的边缘,只需在上面画一个白色矩形:
% arara: pdflatex
\documentclass{article}
\usepackage{tikz}
\usepackage{pigpen}
\newcommand{\testa}{%
\begin{tikzpicture}%
\node [inner sep=0pt, outer sep=0pt] (A) {\pigpenfont E};
\draw [draw=none,fill=white] ([xshift=2.04pt]A.south west) rectangle ([xshift=-2.04pt]A.north east);
\end{tikzpicture}%
}
\newcommand{\testb}{%
\begin{tikzpicture}%
\node [inner sep=0pt, outer sep=0pt] (B) {\pigpenfont E};
\draw [draw=none,fill=white] ([yshift=2.04pt]B.south west) rectangle ([yshift=-2.04pt]B.north east);
\end{tikzpicture}%
}
\begin{document}
{\pigpenfont ABCDEFGHI}\testa\testb
\end{document}
答案4
我认为你寻找的符号不存在。来自此主题\bot 类似带有两条水平线的符号,我构建了您期望的符号:
\documentclass{article}
\usepackage{amsmath,trimclip}
\makeatletter
\DeclareRobustCommand{\Equ}{%
\mathord{\vphantom{\textendash}\mathpalette\mich@Equ\relax}%
}
\newcommand{\mich@Equ}[2]{%
\ooalign{%
$\m@th#1\textendash$\cr
{\raisebox{1.\height}{$\m@th#1\textendash$}}\cr
}%
}
\makeatother
\begin{document}
$\Equ$
$\scriptstyle \Equ$
$\scriptscriptstyle \Equ$
\end{document}
编辑:
此更新允许对您需要的所有符号使用相同的行。它使用MnSymbol
一些已经实现的符号包
\documentclass{article}
\usepackage{amsmath,trimclip}
\usepackage{MnSymbol}
\makeatletter
\DeclareRobustCommand{\Equ}{%
\mathord{\vphantom{\textendash}\mathpalette\mich@Equ\relax}%
}
\newcommand{\mich@Equ}[2]{%
\ooalign{%
{\raisebox{.5\height}{$\m@th#1\minus$}}\cr
{\raisebox{-.5\height}{$\m@th#1\minus$}}\cr
}%
}
\DeclareRobustCommand{\Ver}{%
\mathord{\vphantom{\medvert}\mathpalette\mich@Ver\relax}%
}
\newcommand{\mich@Ver}[2]{%
\ooalign{%
$\m@th#1\,\:\medvert\!\medvert$
}%
}
\makeatother
\begin{document}
\begin{equation}
\begin{array}{cl}
\lefthalfcap & \verb|\lefthalfcap| \\
\lefthalfcup & \verb|\lefthalfcup| \\
\righthalfcap & \verb|\righthalfcap| \\
\righthalfcup & \verb|\righthalfcup| \\
\sqcup & \verb|\sqcup| \\
\sqcap & \verb|\sqcap| \\
\Equ & \verb|\Equ| \\
\Ver & \verb|\Ver| \\
\end{array}
\end{equation}
\end{document}