# Pros and cons using \usepackage and \input used for preamble

Recently, I found a question on how to use preamble kind of thing that we can use for storing the name of the style files and personal macros. I generally use \input{preamble.tex}. What is the pros and cons if I use \usepackage{preamble}?

• Try \input{tikz.sty}\begin{document}Hello!\end{document}. A lot of funny errors appear. As far as I know, \usepackage or actually \RequirePackage does a lot of processing before loading a .sty file and a lot of macro/catcode juggling too. It also cares about versioning, package options... \input just load a file and smiles a "Good luck" to you. – user193767 Jul 6 '20 at 17:20
• \input is really easy to manage, you just do whatever you would've done in your preamble in that file and use \input{foo}. A \usepackage shouldn't use \usepackage but \RequirePackage for any other packages it needs, and it should report back who it is with \ProvidesPackage. A \usepackage will automatically have \makeatletter at its start and \makeatother at its end. Else the two are roughly the same. – Skillmon Jul 6 '20 at 17:34
• @Skillmonlikestopanswers.xyz Can you turn your comment into a response? – AndréC Jul 6 '20 at 18:14
• Related: Creating a default preamble – Alan Munn Jul 6 '20 at 19:25
• it should be noted that MikTeX maintains its own database of sty files and will not recognize a sty tile until it is added to the FNDB. – John Kormylo Jul 7 '20 at 12:30

The \input macro essentially is the same as putting the contents of the input file where the macro is used. So to use it is really easy, you can use anything you would use in your preamble in that file and input it.
Creating a file to be input by \usepackage is a bit more complicated (but not that much). First a file input with \usepackage should report which file that is using \ProvidesPackage (optionally with specifying a date, version, and purpose). Also, a package shouldn't include additional packages with \usepackage, but instead use \RequirePackage. Inside a package you don't have to use \makeatletter at the start and \makeatother at its end.
• note that by design packages may use \usepackage and \ProvidesPackage is optional, so the intention is that it is easier to use \usepackage (as the catcode of @ is managed automatically) – David Carlisle Jul 6 '20 at 21:49
• @user199 no, \RequirePackage will also load packages. The difference is that \RequirePackage can be used before a \documentclass, while \usepackage can't, else the two do the same, that is again a conceptual difference. – Skillmon Jul 7 '20 at 6:52