我想使用 LaTeX2e 或 LaTeX3 宏从\begin{thebibliography}....\end{thebibliography}
环境文本(例如示例------
(6dashes))中查找文本,并在编译时显示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}