答案1
根据我在此处的回答,一个“为了好玩”的答案仅适用于 pdflatex:使用 TrueType 字体勾勒文本轮廓。它可以被清理掉很多。它使用 pdfliterals 来获取 的字形轮廓\widetilde
。
\documentclass{article}
\usepackage{xcolor,amsmath,stackengine}
\input pdf-trans
\newbox\qbox
\def\usecolor#1{\csname\string\color@#1\endcsname\space}
\newcommand\bordercolor[1]{\colsplit{1}{#1}}
\newcommand\fillcolor[1]{\colsplit{0}{#1}}
\newcommand\outline[1]{\leavevmode%
\def\maltext{#1}%
\setbox\qbox=\hbox{\maltext}%
\boxgs{Q q 2 Tr \thickness\space w \fillcol\space \bordercol\space}{}%
\copy\qbox%
}
\newcommand\shadowfy[1]{\expandafter\shadowfypars#1\par\relax\relax}
\long\def\shadowfypars#1\par#2\relax{%
\ifx#1\relax\else
\shadowfywords#1 \relax\relax%
\fi%
\ifx\relax#2\else\par\shadowfypars#2\relax\fi%
}
\def\shadowfywords#1 #2\relax{%
\outline{#1}%
\ifx\relax#2\else\ \shadowfywords#2\relax\fi%
}
\newcommand\colsplit[2]{\colorlet{tmpcolor}{#2}\edef\tmp{\usecolor{tmpcolor}}%
\def\tmpB{}\expandafter\colsplithelp\tmp\relax%
\ifnum0=#1\relax\edef\fillcol{\tmpB}\else\edef\bordercol{\tmpC}\fi}
\def\colsplithelp#1#2 #3\relax{%
\edef\tmpB{\tmpB#1#2 }%
\ifnum `#1>`9\relax\def\tmpC{#3}\else\colsplithelp#3\relax\fi
}
\newcommand\widespecialtilde[1]{%
\stackengine{0pt}{\shadowfy{$\widetilde{\mathcal{#1}}$}}{$\mathcal{#1}$}%
{O}{c}{F}{F}{L}%
}
\begin{document}
\bordercolor{black}
\fillcolor{white}
\def\thickness{.1}
$x = \widespecialtilde{M}$\medskip
\fillcolor{red!50}
\def\thickness{.05}
$y = \widespecialtilde{W}$
\end{document}
答案2
使用技巧这里,可以尝试
\documentclass{article}
\usepackage{amsmath}
\usepackage{wasysym,graphicx}
\usepackage{scalerel,stackengine}
\newcommand{\Pffft}{\rotatebox{90}{\leftmoon}\kern-0.05em\rotatebox{90}{\rightmoon}}
%from https://tex.stackexchange.com/a/337989/121799
\newcommand\reallywidetilde[1]{\ThisStyle{%
\setbox0=\hbox{$\SavedStyle#1$}%
\stackengine{-.1\LMpt}{$\SavedStyle#1$}{%
\stretchto{\scaleto{\SavedStyle\mkern.2mu\AC}{.5150\wd0}}{.6\ht0}%
}{O}{c}{F}{T}{S}%
}}
\newcommand{\reallywidehat}[1]{%
\savestack{\tmpbox}{\stretchto{%
\scaleto{%
\scalerel*[\widthof{\ensuremath{#1}}]
{\kern-.6pt\bigwedge\kern-.6pt}%
{\rule[-\textheight/2]{1ex}{\textheight}}%WIDTH-LIMITED BIG WEDGE
}{\textheight}%
}{0.5ex}}%
\ensurestackMath{\stackon[1pt]{#1}{\tmpbox}}%
}
\newcommand{\DoubleTilde}[1]{%
\savestack{\tmpbox}{\stretchto{%
\scaleto{%
\scalerel*[\widthof{\ensuremath{#1}}]
{\kern-.1pt\Pffft\kern-.1pt}%
{\rule[-\textheight/2]{1ex}{\textheight}}%WIDTH-LIMITED BIG WEDGE
}{\textheight}%
}{1ex}}%
\ensurestackMath{\stackon[1pt]{#1}{\tmpbox}}%
}
\begin{document}
~\DoubleTilde{A}~\DoubleTilde{AB}~\DoubleTilde{\text{koala bear}}
\end{document}
答案3
基本设置(虽然可能不是最好的方法)。正如您所建议的,我没有绘制波浪线,而只绘制了一条横线。这种\hbox
方法的问题在于周围的格式开关会丢失。
\documentclass[]{article}
\usepackage{tikz,mathtools}
\newcommand*\fancytilde[1]{%
\mathchoice
{\fancytildehelper{\displaystyle}{#1}{0.3ex}}
{\fancytildehelper{}{#1}{0.3ex}}
{\fancytildehelper{\scriptstyle}{#1}{0.2ex}}
{\fancytildehelper{\scriptscriptstyle}{#1}{0.15ex}}}
\newcommand*\fancytildehelper[3]{%
\setbox0\hbox{$#1#2$}%
\mathrlap{#2}%
\raisebox{\dimexpr\ht0+#3\relax}{%
\begin{tikzpicture}%
\draw (0,0) -- (\wd0,0);%
\end{tikzpicture}%
}}
\begin{document}
$\fancytilde{foo}_{\fancytilde{bar}_{\fancytilde{baz}}}$
\end{document}
答案4
目前,我有以下临时解决方案,还算比较满意:
\newcommand{\fancytilde}[1]{\overset{\mbox{}\scalebox{1.2}[0.7]{$\approx$}}{#1}}
\newcommand{\Fancytilde}[1]{\overset{\mbox{}\scalebox{2}[0.7]{$\approx$}}{#1}}
我的波浪符号 M 来自
$\fancytilde M$
在文档中。
但是,只要涉及到 TeX,我就不知道该如何调整它。我没能编译上述答案。如果我的命令可以扩展到它的参数就好了(因此我需要两个命令,一个用于单个字母,另一个用于可能更多的符号)。
上面的回答给了我很大的启发,所以谢谢大家!