I want to validate my LaTeX file. I.e. the file should contain only \textit not \it. i want to validate throughout the file with my style command. is there any possibility to do this?
Asked
Active
Viewed 3,059 times
2 Answers
57
You might be interested in the nag package.
\RequirePackage[l2tabu, orthodox]{nag}
\documentclass[<opt>]{<class>}
…
It nags about \it, \bf, …, \centerline, outdated packages and figures and tables without caption
Related: l2tabu
The “sins” of LaTeX users, and how to correct them. The document provides a list of obsolete packages and commands.
Qrrbrbirlbel
- 119,821
11
You could redefine \it to trigger an error if it is used:
Package JOBNAME Error: \it was used!!.
where JOBNAME will be the name of the file that you are processing.
Code:
\documentclass{article}
\def\it{\PackageError{\jobname}{\string\it\space was used!!}}
\begin{document}
\it abc
\end{document}
Peter Grill
- 223,288
-
13@user19551, you should click the checkmark next to the
naganswer to indicate that it resolved your question. – huon Oct 05 '12 at 10:31 -
2What a Harry-Potteresque error message ;-)
\it (The one command that must not be named) has been used!!Very nice :-D – Benedikt Bauer Oct 05 '12 at 21:16 -
2@BenediktBauer: Well before I figured out how to add the back slash, the message was even better "it was used!" :-). – Peter Grill Oct 06 '12 at 00:25
grep '\it\>' > /dev/null. On Unix this should only return an exit status of 0 if there aren't '\itcommands in the file. Of course it won't detect\csname it\endcsnameand friends. BTW why do you want to implement this check? (It may be the case that you also don't want\textitbecause\emph` is what you really want.) – Oct 05 '12 at 08:02