
Me gustaría hacer una superposición de imágenes del capítulo. Hasta ahora he encontrado este código y funciona si especifico la imagen directamente en la definición:
\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}
}
Sin embargo, no puedo entender cómo hacerlo como una macro, es decir, quiero poner "#2" en el nombre de la imagen como marcador de posición y luego puedo pasar un nombre de imagen personalizado como argumento más adelante.
Respuesta1
No tengo idea de cómo pretende que se vea el resultado, ya que no proporcionó un ejemplo de trabajo mínimo, sino simplemente un fragmento de código. De todos modos, debes evitar tikzpicture
los entornos de anidación.
Como sugerí en mi comentario, ¿por qué no creas un comando personalizado \myimagename
donde almacenas el nombre de la imagen actual? Lo mismo podría funcionar para la etiqueta del capítulo; sin embargo, no entendí por su código cómo pretende usar esto.
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}