0

I would like to use nice package tcolorbox for frames together with modern reference system zref.

My \newtcbtheorem looks like:

\newtcbtheorem[auto counter,number within=chapter]{mathexam}{MyExample}{%
   % colback=purple!5,
   % colframe=blue!100!,
   fonttitle=\itshape,        % \bfseries,
   fontupper=\small,
   fontlower=\footnotesize,
   enforce breakable,         % breakable,
   compress page,
   enhanced,
   arc=1pt, left=0pt,right=0pt
}{mai}

but it produce:

LaTeX Warning: Reference `mai:exam038' on page 12 undefined on input line 262.

although I did the translation several times.Is it even possible to use both libraries together?

My motivation to use zrefpackage is to create multivolume book with my school notes from different subjects. Package zref-xref can be used instead of xr-hyperas it is shown in the Heiko Oberdiek's solution.

My complete MNWE is:

\documentclass{scrbook} 
  \usepackage[most]{tcolorbox}
  \newtcbtheorem[auto counter,number within=chapter]{mathexam}{Problem}{%
    % colback=purple!5,
    % colframe=blue!100!,
      fonttitle=\itshape,        % \bfseries,
      fontupper=\small,
      fontlower=\footnotesize,
      enforce breakable,         % breakable,
      compress page,
      enhanced,
      arc=1pt, left=0pt,right=0pt
  }{mai}

\usepackage{nameref}
\usepackage[user, counter]{zref}
%  \usepackage{zref-xr}
%  \zexternaldocument*{example}

\begin{document}
  \chapter{Algebra}\zlabel{chap:math1}
    This is a test for math.
    \begin{equation}
      E=mc^2 \zlabel{eq:1}
    \end{equation}
    This is a second test for math.
    \begin{equation}
      r = \sqrt{x^2 + y^2} \zlabel{eq:2}
    \end{equation}
    In the document A there is chapter \nameref{chap:math1} see the eqation \zref{eq:2}. 

  Solve the problem shown in example \zref{exam038}

  \section{Bunch of examples}
    Let's solve following problems
    \begin{mathexam}{Gauss method}{exam038}
      \(3x + 4y = 5\)
    \end{mathexam}
\end{document}
1
  • 2
    you should know that one need a complete example to test. Apr 30, 2021 at 20:36

1 Answer 1

1

tcolorbox doesn't have support for zref. You could make a feature request, or redefine \label so that issues \zlabel too, or patch a tcolorbox command. nameref can be replaced the titleref module.

\documentclass{scrbook}
  \usepackage[most]{tcolorbox}
  \newtcbtheorem[auto counter,number within=chapter]{mathexam}{Problem}{%
    % colback=purple!5,
    % colframe=blue!100!,
      fonttitle=\itshape,        % \bfseries,
      fontupper=\small,
      fontlower=\footnotesize,
      enforce breakable,         % breakable,
      compress page,
      enhanced,
      arc=1pt, left=0pt,right=0pt,
  }{mai}

\usepackage{nameref}
\usepackage[user, counter,titleref]{zref}
%  \usepackage{zref-xr}
%  \zexternaldocument*{example}

\makeatletter
\pretocmd\tcb@set@label{\zlabel{#1}}{}{\fail}
% if nameref is loaded, else patch \tcb@gettitle
\pretocmd\NR@gettitle{\zref@titleref@setcurrent{#1}}{}{\fail}
%\pretocmd\tcb@gettitle{\zref@titleref@setcurrent{#1}}{}{\fail}
\makeatother
\begin{document}

  \chapter{Algebra}\zlabel{chap:math1}
    This is a test for math.
    \begin{equation}
      E=mc^2 \zlabel{eq:1}
    \end{equation}
    This is a second test for math.
    \begin{equation}
      r = \sqrt{x^2 + y^2} \zlabel{eq:2}
    \end{equation}
    In the document A there is chapter \ztitleref{chap:math1} see the equation \zref{eq:2}.

  Solve the problem shown in example \zref{mai:exam038}

  \section{Bunch of examples}
    Let's solve following problems
    \begin{mathexam}{Gauss method}{exam038}
      \(3x + 4y = 5\)
    \end{mathexam}
    
    \ztitleref{mai:exam038}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .