LaTeX2eマクロを使用してLaTeXファイル全体を読む

LaTeX2eマクロを使用してLaTeXファイル全体を読む

私は LaTeX プラットフォームの初心者 (学習中) ですが、LaTeX2e マクロを使用して完全な LaTeX ファイルを読み、いくつかの置き換えを行いたいと思っています。

私の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{quote}
        The AI for the expected number of XXXX to ZZZZ transitive triads is generally very narrow. Since this statistic reflects relatively high-order structures (because more ties are involved), its range of possible values given the number of edge counts or mutual.
    \end{quote}    
    
    We previously presented a evaluation with visual impairments to assess app usability and accessibility XXXX and ZZZZ.
    Study results unveiled that the app is indeed accessible and usable by people with VIB.
    After the publication remote collection of app usage data, aiming to investigate how end users interact with the system.

\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}

必須:

  1. LaTeXファイルにテキストが含まれている場合は、次のようXXXXにします。LaTeX Compile ErrorLateX Error?
  2. LaTeXファイルにテキストが含まれている場合はZZZZ変更したいです\texttt{ZZZZ}
  3. LaTeXファイル------にテキストが含まれている場合は、次のよう\begin{thebibliography}...\end{thebibliography}にします。LaTeX Compile ErrorLateX Error?

LaTeXのみを使用し、 を使用しないようにするにはどうすればよいですかXeLaTeX/LuaLaTeX?

事前に感謝し、サポートさせていただきます。

私の参考文献マクロ:

\makeatletter
\renewenvironment{thebibliography}[1]{%
 \bibsection
 \parindent\z@
 \bibpreamble
 \bibfont
 \list{\@biblabel{\the\c@NAT@ctr}}{\@bibsetup{#1}\global\c@NAT@ctr\z@}%
 \ifNAT@openbib
   \renewcommand\newblock{\par}%
 \else
   \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}%
 \fi
 \sloppy\clubpenalty4000\widowpenalty4000
 \sfcode`\.\@m
 \let\NAT@bibitem@first@sw\@firstoftwo
    \let\citeN\cite \let\shortcite\cite
    \let\citeasnoun\cite
}{%
 \bibitem@fin
 \bibpostamble
 \def\@noitemerr{%
  \PackageWarning{natbib}{Empty `thebibliography' environment}%
 }%
 \endlist
 \bibcleanup
}%
\makeatother

答え1

環境内のトークンのみを置き換えたい場合は、 と、環境本体を表す引数型 をquote使用して再定義できます。 これで、 を使用して、本体内のトークンを他のトークンに置き換えることができます。例:\NewEnvironmentCopy+bl3

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

\NewEnvironmentCopy{latexquote}{quote}
\ExplSyntaxOn
\tl_new:N \l__quotebody_tl
\RenewDocumentEnvironment { quote } { +b }
  {
    \tl_set:Nn \l__quotebody_tl { #1 }
    \tl_replace_all:Nnn \l__quotebody_tl { XXXX } { \LaTeX{}~Compile~Error }
    \tl_replace_all:Nnn \l__quotebody_tl { ZZZZ } { \textit{\texttt{ZZZZ}} }
    \latexquote
    \l__quotebody_tl
    \endlatexquote
  }
  {
  }
\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{quote}
    The AI for the expected number of XXXX to ZZZZ transitive triads is generally very narrow. Since this statistic reflects relatively high-order structures (because more ties are involved), its range of possible values given the number of edge counts or mutual.
\end{quote}    

We previously presented a evaluation with visual impairments to assess app usability and accessibility XXXX and ZZZZ.
Study results unveiled that the app is indeed accessible and usable by people with VIB.
After the publication remote collection of app usage data, aiming to investigate how end users interact with the system.

\end{document}

ここに画像の説明を入力してください

expl3構文やLaTeX3関数tl_replace_all:Nnn(または\regex_replace_all:nnN)の詳細については、LaTeX3 カーネル

しかし、このようなことはあまり意味がないと思います。David がコメントで述べたように、テキスト内に置換すべきプレースホルダーが必要な場合は、これらのプレースホルダーをマクロとして定義し、次のマクロを使用する方が理にかなっています。

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

\newcommand*\XXXX{XXXX}
\newcommand*\ZZZZ{ZZZZ}

\AddToHook{env/quote/begin}{%
  \renewcommand*\XXXX{%
    \GenericError{}
      {LaTeX Error: \string\XXXX\space used}
      {Don't do it.}
      {Usage of \string\XXXX\space inside quote is not allowed.}%
  }%
  \renewcommand*\ZZZZ{\textit{\texttt{ZZZZ}}}%
}

\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{quote}
    The AI for the expected number of \XXXX{} to \ZZZZ{} transitive triads is generally very narrow. Since this statistic reflects relatively high-order structures (because more ties are involved), its range of possible values given the number of edge counts or mutual.
\end{quote}    

We previously presented a evaluation with visual impairments to assess app usability and accessibility \XXXX{} and \ZZZZ{}.
Study results unveiled that the app is indeed accessible and usable by people with VIB.
After the publication remote collection of app usage data, aiming to investigate how end users interact with the system.

\end{document}

関連情報