![使用 TeX 制作的重新缩放图标](https://linux22.com/image/409366/%E4%BD%BF%E7%94%A8%20TeX%20%E5%88%B6%E4%BD%9C%E7%9A%84%E9%87%8D%E6%96%B0%E7%BC%A9%E6%94%BE%E5%9B%BE%E6%A0%87.png)
几天前,我在这里发布了关于我的 tikz 图片作为图标的信息。所以,你帮助了我,它成功了。但现在,我遇到了一些问题。我希望重新缩放它,以便我可以使用命令\bracket{}{}
。不幸的是,当我按照声明使用它时,当我在此命令中使用它时,它太小了。也许有人可以帮忙并告诉我如何重新缩放它以使用此命令?现在,它被缩放到 X 字母。这是我的这个图标的脚本:
\usepackage{tikz, scalerel}
\def\icon{\scalerel*{\begin{tikzpicture}
\draw[<->, line width=1pt] (-.4,0) -- (.4,0);
\draw[<->, line width=1pt] (0,-.4) -- (0,.4);
\draw[<->, line width=1pt] ({-.4*sin(45)},{-.4*cos(45)}) -- ({.4*sin(45)},{.4*cos(45)});
\draw[<->, line width=1pt] ({-.4*sin(45)},{.4*cos(45)}) -- ({.4*sin(45)}, {-.4*cos(45)});
\end{tikzpicture}}{X}}
答案1
这里有一种方法:
\documentclass{article}
\usepackage{tikz}
\newcommand\mysymb[1][1]{%
\def\myscale{#1}%
\begin{tikzpicture}
\draw[<->, line width={\myscale*1pt}] ({-.4*\myscale},0) -- ({.4*\myscale},0);
\draw[<->, line width={1pt*\myscale}] (0,{-.4*\myscale}) -- ({0,.4*\myscale});
\draw[<->, line width={1pt*\myscale}] ({-.4*sin(45)*\myscale},{-.4*cos(45)*\myscale}) -- ({.4*sin(45)*\myscale},{.4*cos(45)*\myscale});
\draw[<->, line width=1pt*\myscale] ({-.4*sin(45)*\myscale},{.4*cos(45)*\myscale}) -- ({.4*sin(45)*\myscale}, {-.4*cos(45)*\myscale});
\end{tikzpicture}%
}
\newsavebox{\myboxA}
\newsavebox{\myboxB}
\newcommand{\findmyscale}[1]{%
\savebox\myboxA{\hbox{#1}}%
\savebox\myboxB{\hbox{\mysymb}}%
\pgfmathsetmacro\mysc{\the\wd\myboxA/\the\wd\myboxB}%
\xdef\mscale{\mysc}%
}
\begin{document}
X\mysymb X
\findmyscale{X}
X\mysymb[\mscale]X
\end{document}