1

PROBLEM

I have a custom footnote style done with tikz, and inside tcolorboxes this footnote doesn't fit, so I tried that all footnotes inside a tcolorbox environment get out of it with Bernard solution in this question: Footnote outside theorem environment

\usepackage{etoolbox}
\BeforeBeginEnvironment{theorem}{\savenotes}
\AfterEndEnvironment{theorem}{\spewnotes}

Of course it doesn't work, probably because the custom footnote. I was wondering if it was possible to fix this bug

CODE

%%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%

\documentclass[12pt]{report} \usepackage[a4paper, lmargin=2.75cm, rmargin=2.75cm, tmargin=3cm, bmargin=3cm]{geometry} % margins \usepackage[hidelinks, linktoc=all]{hyperref} % \href{link}{text} \usepackage{parskip} % auto new paragraph \setlength{\parskip}{15pt} % more parskip length \usepackage{tikz} \usepackage{tcolorbox} \tcbuselibrary{skins, breakable}

%%%%%%%%%% CUSTOM FOOTNOTE WITH TIKZ %%%%%%%%%%%%%

\usepackage[hang, flushmargin]{footmisc} \usepackage{fancyhdr} \pagestyle{fancy} \renewcommand{\thefootnote}{[\arabic{footnote}]} % footnote config \let\oldfootnote\footnote \renewcommand{\footnote}[1]{\oldfootnote{;#1}} % adds space automatically \newcommand\varfootnote[1] % varfootnote (without number) {\bgroup\renewcommand\thefootnote{\fnsymbol{footnote}}\renewcommand\thempfootnote{\fnsymbol{mpfootnote}}\footnotetext[0]{#1}\egroup} \renewcommand{\footnoterule}{\kern-30pt\tikz{ % custom footnote rule \drawline width=0.4mm--(15.4,0); \drawline width=0.4mm circle (1mm); \filldraw(0,0) circle (0.3mm); \drawline width=0.4mm circle (1mm); \filldraw(15.5,0) circle (0.3mm); \drawcolor=white;}} % moves the line \addtolength{\skip\footins}{2pc plus 5pt}

%%%%%%%%%%%% CUSTOM BOX %%%%%%%%%%%

\newtcolorbox{tbox}[1]{title={\centering\large#1}, fonttitle=\bfseries, toptitle=1.5mm, bottomtitle=1.5mm, enhanced, breakable, colback=yellow, colframe=black, boxrule=1pt, arc=2mm, rounded corners, coltitle=white, coltext=black}

%%%%%%%%%% SUPPOSED FIX %%%%%%%%%%%

\usepackage{etoolbox} \BeforeBeginEnvironment{box}{\savenotes} \AfterEndEnvironment{box}{\spewnotes}

%%%%%%%%%% DOCUMENT %%%%%%%%%%%%

\begin{document}

\footnote{outside footnote}

\begin{tcolorbox}[enhanced, breakable, colback=yellow, colframe=black, boxrule=0pt, arc=2mm, rounded corners, coltext=black, title=\bf{COLORBOX}, coltitle=white, colbacktitle=black, toptitle=1.5mm, bottomtitle=1.5mm]

\varfootnote{inside footnote without number} Random text to fill this up\footnote{inside footnote}

\end{tcolorbox}

\begin{tbox}{title} custom box\footnote{custom box} \end{tbox}

\end{document}

F. Pantigny
  • 40,250

1 Answers1

1

Just a quick workaround is to use the \linewidth to draw the tikz embellishment, and to get everything right use end_of_paragraph\\[vertical_par_spacing_longitude] command with some given spacing like \baselineskip.

RESULT:

enter image description here

MWE:

%%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%

\documentclass[12pt]{report} \usepackage[a4paper, lmargin=2.75cm, rmargin=2.75cm, tmargin=3cm, bmargin=3cm]{geometry} % margins \usepackage[hidelinks, linktoc=all]{hyperref} % \href{link}{text} \usepackage{parskip} % auto new paragraph \setlength{\parskip}{15pt} % more parskip length \usepackage{tikz} \usepackage{tcolorbox} \usepackage{lipsum} \tcbuselibrary{skins, breakable}

%%%%%%%%%% CUSTOM FOOTNOTE WITH TIKZ %%%%%%%%%%%%%

\usepackage[hang, flushmargin]{footmisc} \usepackage{fancyhdr} \pagestyle{fancy} \renewcommand{\thefootnote}{[\arabic{footnote}]} % footnote config \let\oldfootnote\footnote \renewcommand{\footnote}[1]{\oldfootnote{;#1}} % adds space automatically \newcommand\varfootnote[1] % varfootnote (without number) {\bgroup\renewcommand\thefootnote{\fnsymbol{footnote}}\renewcommand\thempfootnote{\fnsymbol{mpfootnote}}\footnotetext[0]{#1}\egroup} \renewcommand{\footnoterule}{\kern-30pt\tikz{ % custom footnote rule \drawline width=0.4mm--(\linewidth,0); \drawline width=0.4mm circle (1mm); \filldraw(0,0) circle (0.3mm); \drawline width=0.4mm circle (1mm); \filldraw(\linewidth,0) circle (0.3mm); \drawcolor=white;}} % moves the line \addtolength{\skip\footins}{2pc plus 5pt}

%%%%%%%%%%%% CUSTOM BOX %%%%%%%%%%%

\newtcolorbox{tbox}[1]{title={\centering\large#1}, fonttitle=\bfseries, toptitle=1.5mm, bottomtitle=1.5mm, enhanced, breakable, colback=yellow, colframe=black, boxrule=1pt, arc=2mm, rounded corners, coltitle=white, coltext=black}

%%%%%%%%%% SUPPOSED FIX %%%%%%%%%%%

\usepackage{etoolbox} \BeforeBeginEnvironment{box}{\savenotes} \AfterEndEnvironment{box}{\spewnotes}

%%%%%%%%%% DOCUMENT %%%%%%%%%%%%

\begin{document} \lipsum*[1]\[0.5\baselineskip]\footnote{\lipsum[2]}

\begin{tcolorbox}[enhanced, breakable, colback=yellow, colframe=black, boxrule=0pt, arc=2mm, rounded corners, coltext=black, title=\bf{COLORBOX}, coltitle=white, colbacktitle=black, toptitle=1.5mm,
    bottomtitle=1.5mm]
    \lipsum[2] whereas \varfootnote{inside footnote without number}
    \lipsum[3]\\[0.5\baselineskip]\footnote{inside footnote}

\end{tcolorbox}


\begin{tbox}{title}
    \lipsum[6]\\[0.5\baselineskip] \footnote{\lipsum[7]}
\end{tbox}
\lipsum[5]

\end{document}


ADDENDUM:

In a more exhaustive review, he found the solution proposed by muzimuzhi Z, in the post Tcolorbox - footnotes at end of each page, review it and give your approval to this great solution; For my part, I only removed the definition that made the decoration look very high and I was deleting the kern command, I hope it is helpful and well, sometimes it is only a matter of formulating a question correctly, otherwise the result will be 42.

RESULT:

enter image description here

MWE:

%%%%%%%%%%% PACKAGES %%%%%%%%%%%%%%

\documentclass[12pt]{report} \usepackage[a4paper, lmargin=2.75cm, rmargin=2.75cm, tmargin=3cm, bmargin=3cm]{geometry} % margins \usepackage[hidelinks, linktoc=all]{hyperref} % \href{link}{text} \usepackage{parskip} % auto new paragraph \setlength{\parskip}{15pt} % more parskip length \usepackage{tikz} \usepackage[hooks]{tcolorbox} \usepackage{lipsum} \tcbuselibrary{skins, breakable}

%%%%%%%%%% CUSTOM FOOTNOTE WITH TIKZ %%%%%%%%%%%%%

\usepackage[hang, flushmargin]{footmisc} \usepackage{fancyhdr} \pagestyle{fancy} \renewcommand{\thefootnote}{[\arabic{footnote}]} % footnote config \let\oldfootnote\footnote \renewcommand{\footnote}[1]{\oldfootnote{;#1}} % adds space automatically \newcommand\varfootnote[1] % varfootnote (without number) {\bgroup\renewcommand\thefootnote{\fnsymbol{footnote}}\renewcommand\thempfootnote{\fnsymbol{mpfootnote}}\footnotetext[0]{#1}\egroup} \renewcommand{\footnoterule}{\tikz{ % custom footnote rule %<---- delete kern adjust. \drawline width=0.4mm--(\linewidth,0); \drawline width=0.4mm circle (1mm); \filldraw(0,0) circle (0.3mm); \drawline width=0.4mm circle (1mm); \filldraw(\linewidth,0) circle (0.3mm); \drawcolor=white;}} % moves the line \addtolength{\skip\footins}{2pc plus 5pt}

%%%%%%%%%%%% CUSTOM BOX %%%%%%%%%%%

\newtcolorbox{tbox}[1]{title={\centering\large#1}, fonttitle=\bfseries, toptitle=1.5mm, bottomtitle=1.5mm, enhanced, breakable, colback=yellow, colframe=black, boxrule=1pt, arc=2mm, rounded corners, coltitle=white, coltext=black}

%%%%%%%%%% SUPPOSED FIX %%%%%%%%%%%

\usepackage{etoolbox} \BeforeBeginEnvironment{box}{\savenotes} \AfterEndEnvironment{box}{\spewnotes} \tcbuselibrary{listings,theorems}

%%%%%%%%%%%%% WORK SOLUTION GIVEN BY muzimuzhi Z ############# % please check and upvote in https://tex.stackexchange.com/a/558922/154390 \makeatletter % restore footnote internals to those in normal page, not minipage \def\tcb@restore@footnote{% \def@mpfn{footnote}% \def\thempfn{\arabic{footnote}}% \let@footnotetext\tcb@footnote@collect }

% collect footnote text \long\def\tcb@footnote@collect#1{% % expand @thefnmark before appending before app to \tcb@footnote@acc \expandafter\gappto\expandafter\tcb@footnote@acc\expandafter{% \expandafter\footnotetext\expandafter[@thefnmark]{#1}% }% }

\def\tcb@footnote@use{% \tcb@footnote@acc \global\let\tcb@footnote@acc@empty } \global\let\tcb@footnote@acc@empty

\tcbset{ % restore for every box every box/.style={ before upper pre=\tcb@restore@footnote }, % use for layer 1 boxes only every box on layer 1/.append style={ after app=\tcb@footnote@use } } \makeatother

%%%%%%%%%% DOCUMENT %%%%%%%%%%%%

\begin{document} \lipsum*[1] \footnote{foot note of the principal text} Principal text.

\begin{tcolorbox}[enhanced, breakable, colback=yellow, colframe=black, boxrule=0pt, arc=2mm, rounded corners, coltext=black, title=\bf{First Colorbox in page}, coltitle=white, colbacktitle=black, toptitle=1.5mm,
    bottomtitle=1.5mm]
    \lipsum*[2] \varfootnote{inside footnote without number} HERE
    \lipsum*[3] \footnote{inside footnote} HERE.  

\end{tcolorbox}

\,\\

\begin{tbox}{title}
    \lipsum[6]\footnote{\lipsum[3]} HERE \lipsum[4] \footnote{\lipsum[2]}
\end{tbox}
\lipsum[5]

\end{document}

J Leon V.
  • 11,533
  • 16
  • 47
  • I thought about moving these footnotes outisde the tcolorbox, though I like this result, but is there a way to automatically give this space in case of a footnote exists? – Agente 156 Jul 19 '23 at 17:42
  • @Agente156 , I think I found the solution but it's either one way or another, it would be nice to be able to place them at will according to need. – J Leon V. Jul 20 '23 at 02:40
  • any solution is welcome – Agente 156 Jul 20 '23 at 10:15