Tcolorbox,练习和 manyfoot 包-2

Tcolorbox,练习和 manyfoot 包-2

我使用该tcolorbox软件包来制作带有解决方案的练习。可以看到,通常的脚注都写在框内,但有时当我有几个脚注时,我会使用该manyfoot软件包以“内联”方式编写这些脚注,但我得到了不想要的结果。只生成了脚注的标记,但没有生成脚注本身。我的目的的第一个问题如下:

Tcolorbox、练习和 manyfoot 包

我现在的问题是:在练习框中,我使用基于练习框后给出的 iniline 项的后缀的命令在框外生成脚注\footnotetextCC并且可以看到它为问题产生了想要的结果(请参阅下面使用的 .tex 文件及其编译)。我如何才能获得解决方案框中脚注的类似方法(可以基于类似 的命令\footnotetextC),从而像练习框一样在解决方案框外生成脚注。

这是使用的 .tex 文件:

\documentclass{book}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins,breakable,xparse}

\usepackage{polyglossia}
\setmainlanguage{english}

\usepackage[para*]{manyfoot}
\DeclareNewFootnote[para]{C}
\makeatletter
\let\c@footnoteC\c@footnote
\makeatother

\renewcommand{\thefootnoteC}{\fnsymbol{footnote}}

\NewTColorBox[auto counter,number within=chapter]{exercise}{+O{}}{%
enhanced,colframe=green!20!black,colback=yellow!10!white,coltitle=green!40!black,
fonttitle=\bfseries,
underlay={\begin{tcbclipinterior}
\shade[inner color=green!80!yellow,outer color=yellow!10!white]
(interior.north west) circle (2cm);
\draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
(interior.south west) grid (interior.north east);
\end{tcbclipinterior}},
title={Exercise~ \thetcbcounter:},
label={exercise@\thetcbcounter},
attach title to upper=\quad,
after upper={\par\hfill\textcolor{green!40!black}%
{\itshape Solution on page~\pageref{solution@\thetcbcounter}}},
lowerbox=ignored,
savelowerto=solutions/exercise-\thetcbcounter.tex,
record={\string\solution{\thetcbcounter}{solutions/exercise-\thetcbcounter.tex}},
#1
}
\NewTotalTColorBox{\solution}{mm}{%
enhanced,colframe=red!20!black,colback=yellow!10!white,coltitle=red!40!black,
fonttitle=\bfseries,
underlay={\begin{tcbclipinterior}
\shade[inner color=red!50!yellow,outer color=yellow!10!white]
(interior.north west) circle (2cm);
\draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
(interior.south west) grid (interior.north east);
\end{tcbclipinterior}},
title={Solution of Exercise~\ref{exercise@#1} on page~\pageref{exercise@#1}:},
phantomlabel={solution@#1},
attach title to upper=\par,
}{\input{#2}}

\tcbset{no solution/.style={no recording,after upper=}}

\begin{document}
\chapter{The first chapter}

\section{Exercises}
\tcbstartrecording
\begin{exercise}
Exercise with inlined footnotes, \footnoteC{inlined footnote 1} and \footnoteC{inlined footnote 2}, in the question.
\tcblower
Exercise with inlined footnotes, \footnoteC{inlined footnote 1} and \footnoteC{inlined footnote 2}, in the answer.
\end{exercise}
\footnotetextC[1]{inlined footnote 1}
\footnotetextC[2]{inlined footnote 2}
\begin{exercise}
Exercise with usual footnotes, \footnote{footnote 1} and \footnote{footnote 2}, in the question.
\tcblower
Exercise with usual footnotes, \footnote{footnote 1} and \footnote{footnote 2}, in the answer.
\end{exercise}
\tcbstoprecording
\section{Solutions of exercises}
\tcbinputrecords

\end{document}

使用 xelatex 进行编译: 在此处输入图片描述

答案1

如果我理解你的问题正确的话,你希望将脚注设置为 ' para' 样式manyfoot,但在 内tcolorbox。该包paranotes可以为你做到这一点。

如果不是因为复杂的“练习解决方案” tcolorbox,自动化“parnotes”会更容易,它依赖于隐式或显式\parnotes命令来打印笔记。但使用部分自动化来做到这一点并不太麻烦。

\documentclass{book}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins,breakable,xparse}

\usepackage{polyglossia}
\setmainlanguage{english}

\usepackage{parnotes}

\NewTColorBox[auto counter,number within=chapter]{exercise}{+O{}}{%
  enhanced,
  colframe=green!20!black,
  colback=yellow!10!white,
  coltitle=green!40!black,
  fonttitle=\bfseries,
  underlay={\begin{tcbclipinterior}
      \shade[inner color=green!80!yellow,outer color=yellow!10!white]
      (interior.north west) circle (2cm);
      \draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
      (interior.south west) grid (interior.north east);
    \end{tcbclipinterior}
  },
  title={Exercise~ \thetcbcounter:},
  label={exercise@\thetcbcounter},
  attach title to upper=\quad,
  after upper={\par\hfill\textcolor{green!40!black}%
    {\itshape Solution on page~\pageref{solution@\thetcbcounter}}%
    \par\parnotes
  },
  lowerbox=ignored,
  savelowerto=exercise-\thetcbcounter.tex,
  record={\string\solution{\thetcbcounter}{exercise-\thetcbcounter.tex}},
  #1,
  code={\parnotereset}, % <-- parnotes
}

\NewTotalTColorBox{\solution}{mm}{%
  enhanced,
  colframe=red!20!black,
  colback=yellow!10!white,
  coltitle=red!40!black,
  fonttitle=\bfseries,
  underlay={\begin{tcbclipinterior}
      \shade[inner color=red!50!yellow,outer color=yellow!10!white]
      (interior.north west) circle (2cm);
      \draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
      (interior.south west) grid (interior.north east);
    \end{tcbclipinterior}},
  title={Solution of Exercise~\ref{exercise@#1} on page~\pageref{exercise@#1}:
  },
  phantomlabel={solution@#1},
  attach title to upper=\par,
}{\input{#2}}

\tcbset{no solution/.style={no recording,after upper=}}

\begin{document}

\chapter{The first chapter}

\section{Exercises}

\tcbstartrecording
\begin{exercise}
  1.  Exercise with inlined footnotes, \parnote{inlined footnote 1}
  and \parnote{inlined footnote 2}, in the question.

  % \parnotes % <-- this won't work because of your "Solution on page ..."

  \tcblower

  2.  Exercise with inlined footnotes, \parnote{inlined footnote 1}
  and \parnote{inlined footnote 2}, in the answer.

  \parnotes

\end{exercise}

% \footnotetextC[1]{inlined footnote 1}
% \footnotetextC[2]{inlined footnote 2}

\begin{exercise}
  Exercise with usual footnotes, \footnote{footnote 1} and
  \footnote{footnote 2}, in the question.

  \tcblower

  Exercise with usual footnotes, \footnote{footnote 1} and
  \footnote{footnote 2}, in the answer.
\end{exercise}
\tcbstoprecording

\section{Solutions of exercises}
\tcbinputrecords

\end{document}

注意:我删除了您的代码以将框写入另一个目录(除非这是问题的重点,否则不应将其包含在 MWE 中)。

tcolorbox-parnote

答案2

根据@jon 给出的答案,我接受我的答案,并给出了我的问题的答案,这实际上是对一个成熟问题的答案...我将这个问题放在阿拉伯语环境中,即从右到左的环境中,拉丁语句子在命令 \LR{} 中给出,该命令从左到右书写。我给出了使用 manyfoot 包的示例,其中我们看到没有写脚注,以及一个使用 parnotes 的示例,我们看到命令 \LR{\parnotes} 以从左到右的模式在框内书写脚注。

以下是获得的.tex 文件:

\documentclass{book}

\usepackage[most]{tcolorbox}
\tcbuselibrary{skins,breakable,xparse}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}
\setmainfont[Script=Arabic,Scale=1.2]{Arial}

\usepackage{parnotes}

\usepackage[para*]{manyfoot}
\DeclareNewFootnote[para]{C}
\makeatletter
\let\c@footnoteC\c@footnote
\makeatother

\renewcommand{\thefootnoteC}{\fnsymbol{footnote}}

\NewTColorBox[auto counter,number within=chapter]{exercise}{+O{}}{%
enhanced,colframe=green!20!black,colback=yellow!10!white,coltitle=green!40!black,
fonttitle=\bfseries,
underlay={\begin{tcbclipinterior}
\shade[inner color=green!80!yellow,outer color=yellow!10!white]
(interior.north west) circle (2cm);
\draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
(interior.south west) grid (interior.north east);
\end{tcbclipinterior}},
title={Exercise~ \thetcbcounter:},
label={exercise@\thetcbcounter},
attach title to upper=\quad,
after upper={\par\hfill\textcolor{green!40!black}%
{\itshape Solution on page~\pageref{solution@\thetcbcounter}}},
lowerbox=ignored,
savelowerto=solutions/exercise-\thetcbcounter.tex,
record={\string\solution{\thetcbcounter}{solutions/exercise-\thetcbcounter.tex}},
#1
}

\NewTotalTColorBox{\solution}{mm}{%
enhanced,colframe=red!20!black,colback=yellow!10!white,coltitle=red!40!black,
fonttitle=\bfseries,
underlay={\begin{tcbclipinterior}
\shade[inner color=red!50!yellow,outer color=yellow!10!white]
(interior.north west) circle (2cm);
\draw[help lines,step=5mm,yellow!80!black,shift={(interior.north west)}]
(interior.south west) grid (interior.north east);
\end{tcbclipinterior}},
title={Solution of Exercise~\ref{exercise@#1} on page~\pageref{exercise@#1}:},
phantomlabel={solution@#1},
attach title to upper=\par,
}{\input{#2}}

\tcbset{no solution/.style={no recording,after upper=}}

\renewcommand{\theparnotemark}{\fnsymbol{parnotemark}} %% The mark for parnote
\renewcommand{\parnotefmt}[1]{\footnotesize\rmfamily
 \noindent\rule{\linewidth}{.5pt}\\ %% The rule before the footnotes
 \noindent #1\par
 \noindent\rule{\linewidth}{.5pt} %% The rule below the footnotes
 }
\begin{document}
\chapter{The first chapter}
\section{Exercises}
\tcbstartrecording
\begin{exercise}
\LR{Exercise with inlined footnotes, using manyfoot, \footnoteC{inlined footnote 1} and \footnoteC{inlined footnote 2}, in the question.}
\tcblower
\LR{Exercise with inlined footnotes, using manyfoot, \footnoteC{inlined footnote 1} and \footnoteC{inlined footnote 2}, in the answer.}
\end{exercise}
\begin{exercise}
\LR{1.  Exercise with inlined footnotes, using parnotes, \parnote{inlined footnote 1} and \parnote{inlined footnote 2}, in the question.}
\LR{\parnotes}
\tcblower
\LR{2.  Exercise with inlined footnotes, using parnotes, \parnote{inlined footnote 1} and \parnote{inlined footnote 2}, in the answer.}
\LR{\parnotes}
\end{exercise}

\begin{exercise}
\LR{Exercise with usual footnotes, \footnote{footnote 1} and \footnote{footnote 2}, in the question.}
\tcblower
\LR{Exercise with usual footnotes, \footnote{footnote 1} and \footnote{footnote 2}, in the answer.}
\end{exercise}
\tcbstoprecording
\section{Solutions of exercises}
\tcbinputrecords
\end{document}

并使用 xelatex 进行编译:

在此处输入图片描述

在此处输入图片描述

相关内容