Flacards 包 - 带变量的 renewcommand

Flacards 包 - 带变量的 renewcommand

我对这个包有疑问flacards。我正在尝试制作扑克牌,其中不同牌的边框颜色不同。这是一个工作示例:

\documentclass[a4paper,frontgrid]{flacards}
\usepackage{aurical}
\usepackage[T1]{fontenc}
\usepackage{ngerman}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,backgrounds,shadows,decorations.pathmorphing,calc,shapes.geometric,patterns}
\usepackage{graphicx}

\usepackage{color}
\usepackage{transparent}
\fboxsep=0mm

\renewcommand{\frfoot}{\footnotesize\thecardno\hskip3pt\smallskip} % change layout for left foot on front
\renewcommand{\brfoot}{}

%Group Colors

\definecolor{griff}{RGB}{224, 57, 35}
\definecolor{slyth}{RGB}{45, 205, 109}

%Command for Card Title:
\renewcommand{\fchead}[1]{\textbf{\Huge{#1}}}

%BACKGROUND

\renewcommand{\flhead}[1]{\texttransparent{0.4} %Background Transparency
{\begin{tikzpicture}[remember picture, overlay]
\node  at (3.18,-4.64) {
   \includegraphics[width=63.47mm, height=92.477mm]{pics/parch4.jpg}
};%
\end{tikzpicture}}
{\begin{tikzpicture}[remember picture, overlay]
\fill[{black}, even odd rule]

(-0.138,-9.24) rectangle ++(63.47mm,92.477mm)
(-0.138 + 0.175,-9.24+0.175) rectangle ++(60mm,89mm);
\end{tikzpicture}}
}

\begin{document}

\Fontskrivan
\pagesetup{3}{3} % 3x3 cards

\card{
\fchead{Test}\\
Test}{Empty}

\end{document}

现在,如果我更新命令\flhead以使其依赖于变量#1,它似乎不起作用,因为预定义的宏无论如何\card都会打印该命令。\flhead

   \renewcommand{\flhead}[1]{\texttransparent{0.4} %Background Transparency
    {\begin{tikzpicture}[remember picture, overlay]
    \node  at (3.18,-4.64) {
       \includegraphics[width=63.47mm, height=92.477mm]{pics/parch4.jpg}
    };%
\end{tikzpicture}}
   {\begin{tikzpicture}[remember picture, overlay]
\fill[{#1}, even odd rule]

(-0.138,-9.24) rectangle ++(63.47mm,92.477mm)
(-0.138 + 0.175,-9.24+0.175) rectangle ++(60mm,89mm);
\end{tikzpicture}}

该命令\flhead有效,但只能单独使用。在\card宏中它无效。

\card{
\flhead{black}
 \fchead{Test}\\
Test}{test}

为什么这不起作用?有什么想法可以起作用吗?这是给我弟弟的礼物,我想在接下来的 10 天内完成它。

PS:如果你好奇我为什么要把框架做得这么复杂,我后来想在内部矩形上应用一些结构。(但这会是一个新问题)

答案1

这里我设置了一个宏\myflhead,它\flhead使用给定的颜色参数重新定义。我认为问题在于,也许\flhead它本身并不打算接受参数。

仍然,\myflhead需要在调用之前调用\card,但可以用来改变边框颜色。

\documentclass[a4paper,frontgrid]{flacards}
\usepackage{aurical}
\usepackage[T1]{fontenc}
\usepackage{ngerman}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,backgrounds,shadows,decorations.pathmorphing,calc,shapes.geometric,patterns}
\usepackage{graphicx}

\usepackage{color}
\usepackage{transparent}
\fboxsep=0mm


\renewcommand{\frfoot}{\footnotesize\thecardno\hskip3pt\smallskip} % change layout for left foot on front
\renewcommand{\brfoot}{}



%Group Colors

\definecolor{griff}{RGB}{224, 57, 35}
\definecolor{slyth}{RGB}{45, 205, 109}


%Command for Card Title:
\renewcommand{\fchead}[1]{\textbf{\Huge{#1}}}


%BACKGROUND

\newcommand\myflhead[1]{%
\renewcommand{\flhead}{\texttransparent{0.4} %Background Transparency
{\begin{tikzpicture}[remember picture, overlay]
\node  at (3.18,-4.64) {
   \includegraphics[width=63.47mm, height=92.477mm]{example-image}
};%
\end{tikzpicture}}
{\begin{tikzpicture}[remember picture, overlay]
\fill[{#1}, even odd rule]

(-0.138,-9.24) rectangle ++(63.47mm,92.477mm)
(-0.138 + 0.175,-9.24+0.175) rectangle ++(60mm,89mm);
\end{tikzpicture}}
}
}
\begin{document}

\Fontskrivan
\pagesetup{3}{3} % 3x3 cards

\myflhead{red}
\card{
\fchead{Test}\\
Test}{Empty}

\myflhead{green}
\card{
\fchead{Test}\\
Test}{Empty}

\end{document}

在此处输入图片描述

或者,为了达到相同的结果,\card可以重新定义为将边框颜色作为可选参数,如下所示

\card[red]{
\fchead{Test}\\
Test}{Empty}

这是 MWE。

\documentclass[a4paper,frontgrid]{flacards}
\usepackage{aurical}
\usepackage[T1]{fontenc}
\usepackage{ngerman}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,backgrounds,shadows,decorations.pathmorphing,calc,shapes.geometric,patterns}
\usepackage{graphicx}

\usepackage{color}
\usepackage{transparent}
\fboxsep=0mm


\renewcommand{\frfoot}{\footnotesize\thecardno\hskip3pt\smallskip} % change layout for left foot on front
\renewcommand{\brfoot}{}



%Group Colors

\definecolor{griff}{RGB}{224, 57, 35}
\definecolor{slyth}{RGB}{45, 205, 109}


%Command for Card Title:
\renewcommand{\fchead}[1]{\textbf{\Huge{#1}}}


%BACKGROUND

\newcommand\myflhead[1]{%
\renewcommand{\flhead}{\texttransparent{0.4} %Background Transparency
{\begin{tikzpicture}[remember picture, overlay]
\node  at (3.18,-4.64) {
   \includegraphics[width=63.47mm, height=92.477mm]{example-image}
};%
\end{tikzpicture}}
{\begin{tikzpicture}[remember picture, overlay]
\fill[{#1}, even odd rule]

(-0.138,-9.24) rectangle ++(63.47mm,92.477mm)
(-0.138 + 0.175,-9.24+0.175) rectangle ++(60mm,89mm);
\end{tikzpicture}}
}
}

\let\svcard\card
\renewcommand\card[2][black]{\myflhead{#1}\svcard{#2}}
\begin{document}

\Fontskrivan
\pagesetup{3}{3} % 3x3 cards

\card[red]{
\fchead{Test}\\
Test}{Empty}

\card[green]{
\fchead{Test}\\
Test}{Empty}

\end{document}

相关内容