
我想使用 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
在排版輸出中包含類似的內容(正如您接受的連結答案所建議的那樣)。由於您已經有了後者的程式碼,所以我修改了卡波哈的回答提供前者。
\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}