
해당 장의 이미지 오버레이를 만들고 싶습니다. 지금까지 이 코드를 찾았으며 정의에서 이미지를 직접 지정하면 작동합니다.
\newcommand\chapterlabel{}
\titleformat{\chapter}
{\gdef\chapterlabel{}
\normalfont\sffamily\Huge\bfseries\scshape}
{\gdef\chapterlabel{\thechapter\ }}{0pt}
{\begin{tikzpicture}[remember picture,overlay]
\node[below right=4.8cm and 0cm of current page.north east] (a)
{\begin{tikzpicture}[remember picture, overlay]
\fill[fill overzoom image=
!!!!!!!!!!!!HERE IS THE IMAGE NAME!!!!!!!!!!!!!!
]
(current page.north west) rectangle
(a);
\node[below right=2.5cm and 2cm of current page.north
west,color=blue]
{\color{white}\chapterlabel#1};
\end{tikzpicture}
};
\end{tikzpicture}
}
그러나 매크로로 만드는 방법을 알 수 없습니다. 즉, 그림 이름에 "#2"를 자리 표시자로 넣은 다음 나중에 사용자 정의 이미지 이름을 인수로 전달할 수 있습니다.
답변1
최소한의 작업 예제를 제공하지 않고 단지 코드 조각만 제공했기 때문에 출력이 어떻게 보이도록 의도했는지 전혀 모르겠습니다. 어쨌든 중첩 tikzpicture
환경은 피해야 합니다.
\myimagename
내 의견에서 제안한 것처럼 현재 이미지의 이름을 저장하는 사용자 정의 명령을 만드는 것이 어떻습니까 ? 장 레이블에도 동일하게 작동할 수 있지만 코드에서 이를 어떻게 사용하려는지 이해하지 못했습니다.
MWE:
\documentclass{report}
\usepackage{titlesec, tikz, tikzfill}
\usetikzlibrary{positioning, shadows}
\newcommand\mychapterlabel{}
\newcommand\myimagename{example-image-a}
\titleformat{\chapter}
{\normalfont\sffamily\Huge\bfseries\scshape}
{\gdef\chapterlabel{\thechapter\ }}{0pt}
{\begin{tikzpicture}[remember picture, overlay]
\coordinate[below right=4.8cm and 0cm of current page.north east] (a);
\fill[fill overzoom image=\myimagename] (current page.north west) rectangle (a);
\node[below right=2.5cm and 2cm of current page.north west, color=blue]
{\color{white}\chapterlabel\mychapterlabel};
\end{tikzpicture}}
\begin{document}
\renewcommand\mychapterlabel{Foo}
\chapter{One}
\renewcommand\mychapterlabel{Bar}
\renewcommand\myimagename{example-image-b}
\chapter{Two}
\end{document}