我在为要编译的宏执行 \pgfkeys 命令时遇到了问题。代码如下。请告诉我哪里出了问题:
\documentclass{article}
\usepackage{graphicx}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{pgfkeys}
%Dictionaries
\pgfkeys{%
/attention/.is family, /attention,
%Here are the defaults
default/.style = {
text size = \large,
text style = \bfseries,
text colour = green,
},
%store the defaults in a command
text size/.store in =\txtsize,
text style/.store in = \txtstyle,
text colour/.store in =\txtcolour,
}%
%Macro
\newcommand{\attention}[2][]{%
\pgfkeys{/attention, default, #1}
{\txtsize\txtstyle\textcolor{\txtcolour}{#2}}
}%
\title{}
\begin{document}
\maketitle
So we are...\attention{Let's get this macro started}... shall we?
\end{document}
答案1
\pgfkeys
删除...中的空白行
\documentclass{article}
\usepackage{graphicx}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{pgfkeys}
% Dictionaries
\pgfkeys{%
/attention/.is family,
/attention,
% Here are the defaults
default/.style = {
text size = \large,
text style = \bfseries,
text colour = green,
},
% store the defaults in a command
text size/.store in =\txtsize,
text style/.store in = \txtstyle,
text colour/.store in =\txtcolour,
}
% Macro
\newcommand{\attention}[2][]{%
\pgfkeys{/attention, default, #1}%
{\txtsize\txtstyle\textcolor{\txtcolour}{#2}}%
}
\title{}
\begin{document}
\maketitle
So we are...\attention{Let's get this macro started}... shall we?
\end{document}