Add a small tcolorbox in the corner of a tcolorbox
This is a bit of a hack (well, two hacks) because I'm not able to find if the frame that tcolorbox
build has a name somewhere. The hacks:
- the magic
\expandafter
(probably using\fpeval
which is expandable it would work better, I don't know)... - You have to manually adjust the numbers in
\splat
... The idea is putting something 0-sized at the start of the item and draw from there.
\documentclass[border=5mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[skins,raster]{tcolorbox}
\newcommand{\splat}[1]{%
\begin{tikzpicture}[overlay, x=\linewidth, y=\linewidth]
\path (1.05,-.65) node [draw, anchor=south east] {#1};
\end{tikzpicture}%
}
\newcommand{\ssplat}[1]{%
\begin{tikzpicture}[overlay, x=\linewidth, y=\linewidth]
#1;
\end{tikzpicture}%
}
\begin{document}
\begin{tcbitemize}[enhanced,
raster columns=4, raster equal height,size=small,sharp corners,
% colframe=red!50!black,colback=red!10!white,colbacktitle=red!50!white,
title={\expandafter\pgfmathparse\expandafter{\thetcbrasternum + 2}\pgfmathprintnumber{\pgfmathresult}}]
\tcbitem Fysikk i væsker og gasser \tcblower Trigonometriske likninger
\tcbitem Fysikk i væsker og gasser \tcblower Trigonometriske likninger
\tcbitem \splat{1}Kjemi
\tcbitem Termofysikk
\tcbitem \splat{2}Vektorer i rommet
\tcbitem Lys
\tcbitem Bølger
\tcbitem Følger
\tcbitem Integrasjon
\tcbitem Differensial-likninger
\tcbitem \ssplat{\draw (0,0) -- (1.05,-.65) (0, -.65) -- (1.05,0)
node[midway, fill=white]{Påske}}
\tcbitem Elektrisitet
\tcbitem Mengdelære
\tcbitem Sannsynlighet
\tcbitem Statikk
\tcbitem Repitisjon
\end{tcbitemize}
\end{document}
(You should use the correct color for the "Påske" box to make it blend, obviously).
A tcbraster
or tcbitemize
defines a general style for all boxes inside the raster but you can apply particular styles to each box. In this case two styles (box
and cross
) are defined to add a box on the corner and a cross out on the background.
About the counter, it's difficult to use thetcbrasternum
, it's easier to define your own counter and initialize as you want.
\documentclass[border=5mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[skins,raster]{tcolorbox}
\newcounter{mycounter}
\setcounter{mycounter}{2}
\tcbset{
box/.style={overlay={\node[anchor=south east, draw] at (frame.south east) {#1};}},
cross/.style={underlay={\draw (interior.north west)--(interior.south east) (interior.north east)--(interior.south west);}}
}
\begin{document}
\begin{tcbitemize}[enhanced,
raster columns=4, raster equal height,size=small,sharp corners,
title={\refstepcounter{mycounter}\themycounter},
]
\tcbitem Fysikk i væsker og gasser \tcblower Trigonometriske likninger
\tcbitem Fysikk i væsker og gasser \tcblower Trigonometriske likninger
\tcbitem[box={1}]Kjemi
\tcbitem Termofysikk
\tcbitem[box=2] Vektorer i rommet
\tcbitem Lys
\tcbitem Bølger
\tcbitem Følger
\tcbitem Integrasjon
\tcbitem Differensial-likninger
\tcbitem[cross, valign=center, halign=center] \tcbox[colback=white, size=small, colframe=white]{Påske}
\tcbitem Elektrisitet
\tcbitem Mengdelære
\tcbitem Sannsynlighet
\tcbitem Statikk
\tcbitem Repitisjon
\end{tcbitemize}
\end{document}