LaTeXのみを使用して特定の環境でコンテンツを読む

LaTeXのみを使用して特定の環境でコンテンツを読む

LaTeX2e または LaTeX3 マクロを使用して、\begin{thebibliography}....\end{thebibliography}例 (6 ダッシュ) のような環境テキストからテキストを検索し、コンパイル時に表示したいと思います。------LaTeX GeneriorError

LaTeX filename.tex

私のMWEは次のとおりです:

\documentclass{article}
        \usepackage{amsmath}
        \usepackage{ragged2e}
        
        \begin{document}
        \title{Book Title}
        \author{Author Name}
        \maketitle
        
    To address these issues, \textit{WordMelodies} a mobile application to support children in the acquisition of basic literacy skills.
    The app was designed to be inclusive for children with and without VIB, thus promoting interaction between them.
    \textit{WordMelodies} also supports children in exercising basic touchscreen interactions on mobile devices.
    
\begin{thebibliography}{}

\bibitem{bib1}
Author N., ``Revisiting the Foundations of Network Analysis,'' {\em Science}, {325},~414--416.

\bibitem{bib2}
``Diagnosing Multicollinearity ------ Random Graph Models,'' {\em Research}, {50},~491--530.

\end{thebibliography}
\end{document}

私はチェックしたLaTeX2eマクロを使用してLaTeXファイル全体を読む環境で動作しません\thebibliography

これを実現するにはどうすればよいでしょうか?

答え1

実際のエラーを生成したいのか(私の質問を理解しようとする不確かな試みに従って)、それともLaTeX GenericErrorタイプセット出力に何かを含めたいのか(あなたが受け入れたリンクされた回答が示唆しているように)はっきりしません。後者のコードは既にあるので、私は修正しましたcabohahの回答前者を提供する。

\documentclass{article}
\usepackage{amsmath}
\usepackage{ragged2e}

% ateb: https://tex.stackexchange.com/a/705721/ addaswyd o ateb cabohah: https://tex.stackexchange.com/a/705318/
\NewEnvironmentCopy{thebibliographyorig}{thebibliography}
\ExplSyntaxOn
\tl_new:N \l__kavi_bibbody_tl
\RenewDocumentEnvironment { thebibliography } { +b }
{
  \tl_set:Nn \l__kavi_bibbody_tl { #1 }
  \tl_replace_all:Nnn \l__kavi_bibbody_tl { ------ } { \PackageError{kavi}{ LaTeX ~ GenericError }{Don't ~ use ~ six ~ hyphens ~ in ~ a ~ row! } }
  \expandafter
  \thebibliographyorig
  \l__kavi_bibbody_tl
  \endthebibliographyorig
}{}
\ExplSyntaxOff

\begin{document}
\title{Book Title}
\author{Author Name}
\maketitle

To address these issues, \textit{WordMelodies} a mobile application to support children in the acquisition of basic literacy skills.
The app was designed to be inclusive for children with and without VIB, thus promoting interaction between them.
\textit{WordMelodies} also supports children in exercising basic touchscreen interactions on mobile devices.
    
\begin{thebibliography}{}

\bibitem{bib1}
Author N., ``Revisiting the Foundations of Network Analysis,'' {\em Science}, {325},~414--416.

\bibitem{bib2}
``Diagnosing Multicollinearity ------ Random Graph Models,'' {\em Research}, {50},~491--530.

\end{thebibliography}
\end{document}

関連情報