![制作(糟糕的)自定义 sqrt 符号](https://linux22.com/image/443454/%E5%88%B6%E4%BD%9C%EF%BC%88%E7%B3%9F%E7%B3%95%E7%9A%84%EF%BC%89%E8%87%AA%E5%AE%9A%E4%B9%89%20sqrt%20%E7%AC%A6%E5%8F%B7.png)
答案1
不需要 Tikz(或任何特定于驱动程序\special
的):-)
\documentclass{article}
\begin{document}
\begin{picture}(100,100)
\thicklines
\put(40,50){\line(-1,6){3}}
\thinlines
\put(40,50){\line(1,6){5}}
\put(45,80){\line(1,0){25}}
\put(57,77){\line(1,-1){10}}
\put(57,77){\line(-1,-1){10}}
\put(50,50){\Huge\textsf{X}}
\end{picture}
\end{document}
答案2
感谢 David 的回答。避免依赖关系本来会更好,但最终我选择了 TikZ 版本,使用它的相对定位、自动模式等。欢迎改进。
\documentclass{article}
\usepackage{tikz,calc}
\usetikzlibrary{positioning}
\newcommand{\badsqrt}[1]{\tikz[baseline=(x.base)]{%
\node(x){\ensuremath{#1}};
\coordinate[above left= 0.8ex and 0.01ex of x.west] (a);
\coordinate[below right= 0.1ex and 0.3ex of x.base west] (b);
\coordinate[left= 0.03ex of b] (b2);
\coordinate[below right= 0.1ex and 0.45ex of x.north west] (c);
\coordinate[above right= 0.02ex and 0.05ex of c] (c2);
\coordinate[below left= 0.1ex and 0.4ex of x.north east] (d);
\draw[-, thick] (a)--(b);
\draw[-] (b2)--(c2);
\draw[-] (c)--(d);
}}
\newlength{\badhatxw}
\newcommand{\badhat}[1]{\tikz[baseline=(x.base)]{%
\node[inner sep=0,outer sep=0] (x){\ensuremath{#1}};
\settowidth{\badhatxw}{\ensuremath{#1}}
\coordinate[below left= 0.01ex and 0.5\badhatxw of x.north] (l);
\coordinate[below right= 0.03ex and 0.52\badhatxw of x.north] (r);
\coordinate[above right= 0.6ex and 0.02ex of x.north] (c1);
\coordinate[above left= 0.59ex and 0.03ex of x.north] (c2);
\draw[-, inner sep=0,outer sep=0] (l)--(c1);
\draw[-, inner sep=0,outer sep=0] (r)--(c2);
}}
\begin{document}
\section*{Check this out: \protect\badsqrt{x}}
How do \badsqrt{x}, \badsqrt{X}, \badsqrt{\int f(x) \mathrm{d}x},\\
{\Huge \badsqrt{x}}, {\Huge \badsqrt{\badhat{x}}}, and \badsqrt{\badhat{x}} look?
\end{document}