\tableofcontents에서 오류 없이 \section을 재정의하는 방법

\tableofcontents에서 오류 없이 \section을 재정의하는 방법

섹션을 재정의하고 \tableofcontents를 사용할 때 오류가 발생하는 것을 발견했습니다.

! LaTeX 오류: 뭔가 잘못되었습니다. 아마도 \item이 누락되었을 수 있습니다.

이 문제를 해결하도록 도와주세요. 도움을 주신 모든 분들께 진심으로 감사드립니다.

\documentclass{article}
\usepackage{tagpdf}
\tagpdfsetup{tabsorder=structure,uncompress,activate-all,add-new-tag=Title/P,interwordspace=true}
\ExplSyntaxOn
\makeatletter
\prop_gset_from_keyval:Nn{\g__sections_prop}{chapter=H1,section=H2,subsection=H3,subsubsection=H4}
\prop_map_inline:Nn \g__sections_prop{
\cs_set_eq:cc{orig@#1}{#1}
\cs_gset_protected:cpn{#1}##1{
\tagstructbegin{tag=#2}
\tagmcbegin{tag=#2}
\use:c{orig@#1}{##1x}
\tagmcend
\tagstructend
}
}
\makeatother
\ExplSyntaxOff
\author{Alexandr Kozlovskiy}
\title{test}
\begin{document}
\tagstructbegin{tag=Document}
\tagstructbegin{tag=Title}
\tagmcbegin{tag=Title}
\maketitle
\tableofcontents
\tagmcend
\tagstructend
\section{test}
\tagstructbegin{tag=P}
\tagmcbegin{tag=P}
new test
\tagmcend
\tagstructend

\section{new test}

\tagstructbegin{tag=P}
\tagmcbegin{tag=P}
new test again
\tagmcend
\tagstructend
\tagstructend
\end{document}

관련 정보