
나는 TeX와 LaTeX를 처음 접했고 나의 첫 번째 프로젝트는 매우 야심찬 프로젝트였습니다. 계획은 ltxkeys
D&D 롤플레잉 게임에 대한 데이터베이스 항목을 정의하는 데 사용하고 LaTeX 템플릿을 사용하여 캐릭터 시트, 몬스터 통계 등을 예쁘게 인쇄하는 것입니다. 저는 이제 막 시작했고 약간의 성공을 거두었지만 이 테스트 파일에 문제가 있습니다:
\documentclass[letterpaper,landscape]{article}
\pagestyle{empty}
\usepackage[T1]{fontenc}%Use a modern font encoding
\usepackage[sfdefault]{noto}
\usepackage[margin=.5in,nohead,nofoot]{geometry}
\usepackage{graphbox}% Loads graphicx automagically.
\usepackage{anyfontsize}
\usepackage{textpos}
\usepackage[tracingkeys]{ltxkeys}
\setlength{\TPHorizModule}{1in}
\setlength{\TPVertModule}{1in}
\makeatletter
% Monster Tent Graphic is 300 DPI with:
% * image size of (600x2250 pixels) 2in x 7.5in
% * monster title of 630x62 pixels (2.1in x .207in)
% Use a Data Key: \DnD{WUMPUS}{image}
\newcommand{\DnD}[2]
{%
{%
\def\c{#1}
\def\v{#2}
\def\t {\csname DnD@KeyFam@\c \endcsname}%
\csname cmd\t @\c @\v \endcsname%
}%
}
% Define a Creature Data Key:
% \DnDNewCreature{WUMPUS}{title="Grand Wumpus", image=..."}
\newcommand{\DnD@NewCreature}[2]%
{%
\ltxkeys@declarekeys[DnD@Creature]{#1}%
{ cmd/\needvalue{title}//;
cmd/\needvalue{image}//;
}%
\expandafter\def\csname DnD@KeyFam@#1\endcsname{DnD@Creature}%
\ltxkeys@setkeys[DnD@Creature]{#1}{#2}%
}
\def\gimg {img/MM167-Goblin-BW.png}
\DnD@NewCreature{GoblinBoss}{title=Goblin Boss,image=img/MM167-Goblin-BW.png}
\begin{document}%
\def\m {GoblinBoss}%
\begin{figure}[t]%
\begin{minipage}{.25\textwidth}%
% \includegraphics[smash=cc,width=2in,totalheight=2.5in,keepaspectratio,angle=180,hshift=-1.25in,vshift=-2.1in]{\DnD{GoblinBoss}{image}}
\includegraphics[smash=cc,width=2in,totalheight=2.5in,keepaspectratio,angle=180,hshift=-1.25in,vshift=-2.1in]{img/MM167-Goblin-BW.png}%
\includegraphics[smash=cr,totalheight=7.5in,width=2.5in]{img/Monster-Tent.png}%
\begin{textblock}{2.1}(.2,-.42)%
\rotatebox[origin=c]{180}
{\centerline{\fontsize{16}{16}\textbf{\DnD{GoblinBoss}{title}}}}
\end{textblock}
\end{minipage}%
\end{figure}
\end{document}
\makeatother
있는 그대로 파일은 몬스터 텐트 이미지를 올바르게 렌더링하고 원하는 이미지와 제목을 올바르게 배치합니다. 그러나 이는 \includegraphics
명령이 ltxkey
. \includegraphics
두 번째 명령 대신 첫 번째 주석 처리된 명령을 사용하면 includegraphics 내부에서 "Illegal parameter number in definition of \filename@base"
.
대신에 이미지 파일 경로로 정의된 것을 ltxkey
사용 하면 작동합니다. 여기에 코드를 입력 하도록 \gimg
정의하려고 하면 다시 실패합니다. 방금 값을 인쇄하면 올바른 것으로 보입니다. 어떤 도움이라도 주시면 감사하겠습니다.\gimg
{\DnD{GoblinBoss}{image}}
\DnD{GoblinBoss}{image}
답변1
이미지 파일 이름으로 확장되도록 명령을 정의해야 합니다.
\documentclass[letterpaper,landscape]{article}
\pagestyle{empty}
\usepackage[T1]{fontenc}%Use a modern font encoding
\usepackage[sfdefault]{noto}
\usepackage[margin=.5in,nohead,nofoot]{geometry}
\usepackage{graphbox}% Loads graphicx automagically.
\usepackage{anyfontsize}
\usepackage{textpos}
\usepackage[tracingkeys]{ltxkeys}
\setlength{\TPHorizModule}{1in}
\setlength{\TPVertModule}{1in}
\makeatletter
% Monster Tent Graphic is 300 DPI with:
% * image size of (600x2250 pixels) 2in x 7.5in
% * monster title of 630x62 pixels (2.1in x .207in)
% Use a Data Key: \DnD{WUMPUS}{image}
\newcommand{\badDnD}[2]
{%
{%non expandable group start
\def\c{#1} % non expandable assignment and space token
\def\v{#2} % non expandable assignment and space token
\def\t {\csname DnD@KeyFam@\c \endcsname}% non expandable assignment
\csname cmd\t @\c @\v \endcsname%
}%non expandable group end
}
\newcommand{\DnD}[2]{\csname cmd\csname DnD@KeyFam@#1\endcsname @#1@#2\endcsname}
% Define a Creature Data Key:
% \DnDNewCreature{WUMPUS}{title="Grand Wumpus", image=..."}
\newcommand{\DnD@NewCreature}[2]%
{%
\ltxkeys@declarekeys[DnD@Creature]{#1}%
{ cmd/\needvalue{title}//;
cmd/\needvalue{image}//;
}%
\expandafter\def\csname DnD@KeyFam@#1\endcsname{DnD@Creature}%
\ltxkeys@setkeys[DnD@Creature]{#1}{#2}%
}
\def\gimg {img/MM167-Goblin-BW.png}
\DnD@NewCreature{GoblinBoss}{title=Goblin Boss,image=example-image.png}
\begin{document}%
\def\m {GoblinBoss}%
\begin{figure}[t]%
\begin{minipage}{.25\textwidth}%
\includegraphics[smash=cc,width=2in,totalheight=2.5in,keepaspectratio,angle=180,hshift=-1.25in,vshift=-2.1in]{\DnD{GoblinBoss}{image}}
\includegraphics[smash=cc,width=2in,totalheight=2.5in,keepaspectratio,angle=180,hshift=-1.25in,vshift=-2.1in]{example-image-a.png}%
\includegraphics[smash=cr,totalheight=7.5in,width=2.5in]{example-image-b.png}%
\begin{textblock}{2.1}(.2,-.42)%
\rotatebox[origin=c]{180}
{\centerline{\fontsize{16}{16}\textbf{\DnD{GoblinBoss}{title}}}}
\end{textblock}
\end{minipage}%
\end{figure}
\end{document}
\makeatother this is never executed