修复与 .sty 文件相关的错误

修复与 .sty 文件相关的错误

首先,如果我没有使用正确的技术术语,请原谅我。我不是 LaTeX 专家。我正在使用 Overleaf 编写一些 .tex 文件,并且我有一个包含环境(例如名为“correction”的文件)的 .sty 文件。当我编译时,每次我执行 \begin{correction} 时,都会出现错误:

程序包 pgfkeys 错误:我不知道密钥“/tcb/correction”,我将忽略它。也许您拼错了。

它会将我发送到特定的行(行三十九)。但我真的不知道错误在哪里。我试图理解,与前面的段落进行比较,看看是否缺少了什么。但我什么也没发现。

代码确实可以运行。尽管有错误,但我确实拥有我想要的“更正”环境,但我想了解这个错误来自哪里。我不知道tcb/correction错误消息中的意思是什么。

这是 MWE 和完整的.sty 文件:

\documentclass[a4paper,11pt,fleqn]{article}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
% \usepackage[sujet]{pas-correction}
\usepackage[correction]{pas-correction}


  \begin{document}

    \bigskip

% Ex1
\textbf{Exercice 1}\\

The question..


\begin{correction}
  The solution..
\end{correction}


\end{document}

.sty 文件(pas-correction.sty)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                               %
%        pas-correction  v1.02  encodage : UTF8                 %
%                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                               %
%           Créé par Stéphane PASQUET                           %
%                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Objet : créer un document avec ou sans le corrigé
% Informations générales
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pas-correction}[2020/07/14]
\RequirePackage{tcolorbox} %salma:[many]
    \tcbuselibrary{skins,magazine}
\newif\if@correction
\newif\if@sujet
\DeclareOption{correction}{\@correctiontrue}
\DeclareOption{sujet}{\@sujettrue}
\ProcessOptions

% Styles par défaut



\newcount\@visibility
\@visibility\z@

%----------> Portion de code due à  Christian Tellechea (alias "un bon petit")
\newwrite\sav@body
\newcount\sav@cnt
\def\grab@body{\begingroup\sav@cnt\z@\loop
   \ifnum\sav@cnt<\@cclvi\catcode\sav@cnt12 \advance\sav@cnt\@ne\repeat
   \newlinechar`\^^M \grab@body@i}
\begingroup\edef\tmp@namedef{\endgroup\long\def\noexpand\grab@body@i##1\expandafter\@gobble\string\\\detokenize{end{document}}}
\tmp@namedef{%
   \immediate\openout\sav@body\jobname.sav
   \immediate\write\sav@body{#1}\immediate\closeout\sav@body
   \endgroup\if@sujet\maketitlesubject\input\jobname.sav\fi\if@correction\advance\@visibility\@ne\if@sujet\newpage\fi\maketitlecorrection\input\jobname.sav\fi
   \end{document}
   \ingnorespaces}
\g@addto@macro\document\grab@body
%----------> Fin du code


% Environnement "correction"


\newsavebox{\@correc@box}
\newenvironment{correction}
{% 
    \ifnum\@visibility=1
        \begin{tcolorbox}[correction,title=Corrigé,breakable, width=\textwidth, enhanced]
    \else 
        \begin{lrbox}{\@correc@box}
        \begin{minipage}{\linewidth}
    \fi 
} 
{%

    \ifnum\@visibility=1
        \end{tcolorbox}
    \else
        \end{minipage}
        \end{lrbox}
    \fi
}

% macros  pour les titres
% \setcounter{count@exo}{0}%%salma
% \setcounter{thecounter}{0}%%salma
\def\@newtitlesubject{}
\newcommand\newtitlesubject[1]{\def\@newtitlesubject{#1}}
\def\@newtitlecorrection{}
\newcommand\newtitlecorrection[1]{\def\@newtitlecorrection{#1}}

%\newcommand\titlesubject[1]{\edef\@title@subject@name{#1}}
%\newcommand\maketitlesubject{\ifx\@newtitlesubject\@empty\begin{center}\begin{tcolorbox}[title]\@title@subject@name\end{tcolorbox}\end{center}\else\@newtitlesubject\fi}
%\newcommand\titlecorrection[1]{\edef\@title@correction@name{#1}}
%\newcommand\maketitlecorrection{\ifx\@newtitlesubject\@empty\begin{center}\begin{tcolorbox}[title]\@title@correction@name\end{tcolorbox}\end{center}\else\@newtitlecorrection\fi}
\newcommand\newpageforsubject{\ifnum\@visibility=0\newpage\fi}
\newcommand\newpageforcorrection{\ifnum\@visibility=1\newpage\fi}
\newcommand{\dottedlinesubject}{\ifnum\@visibility=0\dotfill\fi}

% suppression du fichier auxiliaire

\AtEndDocument{\immediate\write18{erase \jobname.sav}}

相关内容