# Is there any possibility to validate a LaTeX file?

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?

-
– Peter Grill Oct 5 '12 at 7:12
Perhaps an easier way is grep '\it\>' > /dev/null. On Unix this should only return an exit status of 0 if there aren't '\it commands in the file. Of course it won't detect \csname it\endcsname and friends. BTW why do you want to implement this check? (It may be the case that you also don't want \textit because \emph is what you really want.) – Marc van Dongen Oct 5 '12 at 8:02

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.

-

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}

-
Thanks. nag package is worked fine. – user19551 Oct 5 '12 at 9:53
@user19551, you should click the checkmark next to the nag answer to indicate that it resolved your question. – huon Oct 5 '12 at 10:31
What a Harry-Potteresque error message ;-) \it (The one command that must not be named) has been used!!` Very nice :-D – Benedikt Bauer Oct 5 '12 at 21:16
@BenediktBauer: Well before I figured out how to add the back slash, the message was even better "it was used!" :-). – Peter Grill Oct 6 '12 at 0:25