我想将自定义箭头形状定义为一个\newcommand
宏,该宏接受一个参数,即应出现在箭头右侧的标签。但是以下代码在序言中不起作用:
\newcommand{\arrowdown}{1}{
\tikz[baseline=-1ex]{\node [draw, fill=orange, single arrow,
minimum height=3.5ex, single arrow head extend=1ex,
rotate=-90, right] {#1};}
}
我收到以下错误:
You can't use `macro parameter character #' in restricted horizontal mode. Missing \begin{document}.
答案1
正如艾伦所建议的,在定义时使用[]
而不是。{}
newcommand
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\newcommand{\arrowdown}[1]{%
\tikz[baseline=-1ex]{\node [draw, fill=orange, single arrow,
minimum height=3.5ex, single arrow head extend=1ex,
rotate=-90, right] {#1};}
}
\begin{document}
\arrowdown{Hello World}
\end{document}