I'm trying to make a custom caption format and want to put an overlay in the tcolorbox
environment, but it does not seem to like having the overlay option in the definition of the tcolorbox
. It compiles fine without the overlay but gives the error:
Argument of \@tempa has an extra }
\documentclass[8pt,openany]{book}
\usepackage[english]{babel} % for typography, proper hyphenation, etc
\usepackage{hyperref} % creating hyperlinks
\urlstyle{same}
\hypersetup{
colorlinks=true, % replace boxed coloring with text coloring
urlcolor=blue, % color of external links
}
\usepackage{graphicx} % importing images
\usepackage{float} % necessary for creating floating env
\usepackage{fontspec}
\setmainfont{LiberationSerif}
\usepackage{calc}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt} % remove header underline
\usepackage{tikz}
\usepackage{mdframed}
\usepackage{caption}
\usepackage[many]{tcolorbox}
\usepackage{color}
\usepackage{titlesec}
\usepackage{wrapfig}
\definecolor{dc-text}{RGB}{60,60,60}
\definecolor{dc-base}{RGB}{150,150,150}
\definecolor{dc-box}{RGB}{200,200,200}
\DeclareCaptionFormat{tcbcaption}{%
\begin{tcolorbox}[
colback=dc-box,
arc=0pt,
outer arc=0pt,
colframe=dc-box,
boxrule=0pt,
colupper=dc-text,
fontupper=\fontspec{LiberationSans-Regular.ttf}\fontsize{8}{10}\selectfont,
boxsep=0pt,
overlay={\path[draw=\chbasecolor] (frame.north west) -- (frame.south east);}
]
{\fontspec{LiberationSans-Bold.ttf}\fontsize{8}{10}#1#2}#3
\end{tcolorbox}%
}
\captionsetup{format=tcbcaption}
\begin{document}
\begin{figure}[t]%default t
\centering
\includegraphics[width=\pagewidth]{example-image-a}
\caption{Foo}
\end{figure}%
\end{document}
\fontspec
settings to fonts not everybody has installed and there is no\pagewidth
length – user31729 Sep 27 '17 at 16:15