깨질 수 있는 tcolorbox가 포함된 각주

깨질 수 있는 tcolorbox가 포함된 각주

하나의 글로벌 각주 시스템(번호 매기기)을 가지려고 하는데 깨질 수 있는 tcolorbox에 몇 가지 문제가 있는 것 같습니다. 내가 읽은 답변 중 상당수는 단일 글로벌 각주 시스템에 대한 간단한 요구 사항에 비해 너무 발전된 것 같습니다.

내 서문은

\documentclass[a4paper,10pt,titlepage]{article}
\usepackage[utf8]{inputenc}
\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}
\usepackage[a4paper,margin=3.5cm]{geometry} %Sets the page geometry
\usepackage{url}
\usepackage{dirtytalk}
\usepackage{graphicx} % Package for \includegraphics
\usepackage{wrapfig} % Figure wrapping
\usepackage[T1]{fontenc} % Output font encoding for international characters
\setlength{\parskip}{1em} % Set space when paragraphs are used
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{hyperref}
\usepackage{mathrsfs}
\usepackage{mdframed}
\usepackage[breakable]{tcolorbox}
\usepackage[justification=centering]{caption}
\usepackage{soul}

% Note that we enforce things so that everything is numbered off of theorems
\theoremstyle{definition} % to avoid italicizing theorems
\newmdtheoremenv{theo}{Theorem}
\newtheorem{thm}{Theorem}[section] % reset theorem numbering for each chapter
\newtheorem{defn}[thm]{Definition} % definition numbers are dependent on theorem numbers
\newtheorem{rmk}[thm]{Remark}
\newtheorem{exmp}[thm]{Example} % same for example numbers
\newtheorem{crlry}[thm]{Corollary}
\newtheorem{lemma}[thm]{Lemma}
\newtheorem{problem}{Problem}[section]

%% HOW TO KEEP FOOTNOTES GLOBAL
\usepackage{footnote}
\usepackage{etoolbox}
\BeforeBeginEnvironment{tcolorbox}{\savenotes}
\AfterEndEnvironment{tcolorbox}{\spewnotes}
\usepackage{blindtext}

\usepackage{geometry}
    %\usepackage{showframe} %This line can be used to clearly show the new margins

\newgeometry{vmargin={25mm}, hmargin={22mm,22mm}}

% Lets you use \blankpage to make a blank page
\newcommand{\blankpage}{
\newpage
\thispagestyle{empty}
\mbox{}
\newpage
}

내 각주 예는 다음과 같습니다.

\begin{tcolorbox}[breakable]
\begin{defn}[Equivalence class]
    Given an equivalence relation $\equiv$ defined on a set $S$, we define the equivalence class corresponding to any $a \in S$ as the set\footnote{If the equivalence relation in question is understood from context we'll sometimes just write $[a]$.}
    $$[a]_\equiv = \{ b \in S | a \equiv B \}$$
\end{defn}
\end{tcolorbox}

내 문제의 예가 아래 그림에 나와 있습니다(각주 "a"로 시작하는 두 개의 tcolorbox를 참고하세요). tcolorboxes 외부에서 수행하는 모든 작업에는 문제가 없으며 전역적이고 올바르게 증가합니다.

여기에 이미지 설명을 입력하세요

어떤 도움이라도 대단히 감사하겠습니다. 감사합니다!

답변1

이는 \BeforeBeginEnvironment및 를 모두 결합합니다 \renewenvironment. 선택적 인수 앞이나 뒤에 명령을 실행하는 것과 관련이 있습니다.

\documentclass[a4paper,10pt,titlepage]{article}
\usepackage[utf8]{inputenc}
\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}
\usepackage[a4paper,margin=3.5cm]{geometry} %Sets the page geometry
\geometry{vmargin={25mm}, hmargin={22mm,22mm}}

\usepackage{url}
%\usepackage{dirtytalk}
\usepackage{graphicx} % Package for \includegraphics
\usepackage{wrapfig} % Figure wrapping
\usepackage[T1]{fontenc} % Output font encoding for international characters
\setlength{\parskip}{1em} % Set space when paragraphs are used
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{mathrsfs}
\usepackage{mdframed}
\usepackage[justification=centering]{caption}
\usepackage{soul}

% Note that we enforce things so that everything is numbered off of theorems
\theoremstyle{definition} % to avoid italicizing theorems
\newmdtheoremenv{theo}{Theorem}
\newtheorem{thm}{Theorem}[section] % reset theorem numbering for each chapter
\newtheorem{defn}[thm]{Definition} % definition numbers are dependent on theorem numbers
\newtheorem{rmk}[thm]{Remark}
\newtheorem{exmp}[thm]{Example} % same for example numbers
\newtheorem{crlry}[thm]{Corollary}
\newtheorem{lemma}[thm]{Lemma}
\newtheorem{problem}{Problem}[section]

%% HOW TO KEEP FOOTNOTES GLOBAL
\usepackage[breakable]{tcolorbox}
\usepackage{footnote}
\BeforeBeginEnvironment{tcolorbox}{\savenotes}
\AfterEndEnvironment{tcolorbox}{\spewnotes}
\makeatletter
\let\oldtcolorbox=\tcolorbox
\let\endoldtcolorbox=\endtcolorbox
\renewenvironment{tcolorbox}[1][]{\oldtcolorbox[#1]%
  \def\@mpfn{footnote}%
  \def\thempfn{\thefootnote}}%
{\endoldtcolorbox}
\makeatother

\usepackage{hyperref}

% Lets you use \blankpage to make a blank page
\newcommand{\blankpage}{
\newpage
\thispagestyle{empty}
\mbox{}
\newpage
}
\begin{document}
Test\footnote{First}

\begin{tcolorbox}[breakable]
\begin{defn}[Equivalence class]
    Given an equivalence relation $\equiv$ defined on a set $S$, we define the equivalence class corresponding to any $a \in S$ as the set\footnote{If the equivalence relation in question is understood from context we'll sometimes just write $[a]$.}
    $$[a]_\equiv = \{ b \in S | a \equiv B \}$$
\end{defn}
\end{tcolorbox}
\end{document}

관련 정보