几天前,我在这里发布了关于我的 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}