38

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?

  • 1
    Welcome to TeX.SE. – Peter Grill Oct 5 '12 at 7:12
  • 3
    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.) – user10274 Oct 5 '12 at 8:02
56

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.

| improve this answer | |
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}
| improve this answer | |
  • 13
    @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
  • 2
    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
  • 2
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.