I have some doubt about the correct approach to document modularity. Main main doubt is about the usage of custom packages in the creation of a complex structure document. In my first LaTeX work I made a custom package (.sty) with structure / commands definitions and other global settings. This allowed me to fix several compilation issues I had placing everything in a single file but I soon noticed some negative drawbacks about such approach:

  • the custom .sty package referenced trough \usepackage directive is not found/recognized by TeXstudio editor (altough it is correctly compiled by LaTeX).

  • compilation errors in custom package are 'mitigated' and anyway is often difficult to find the correct reference to the error.

  • the templates / sample files I read learning LaTeX did not use such approach but often use \inlcude \input directives.

This's my document structure:



\author{The Author}
\title{The Title}
\editor{The Editor}










and this is my custom package (the name is defines.sty):


\usetikzlibrary{backgrounds, calc}



    \begin{tikzpicture}[remember picture, overlay, color=LimeGreen]
            \node[anchor=north west](CNW) at (current page.north west){
            \node[anchor=north east](CNE) at (current page.north east){
            \node[anchor=south west](CSW) at (current page.south west){
            \node[anchor=south east](CSE) at (current page.south east){

    \includegraphics[width = 30mm]{logo.png}



    \begin{tikzpicture}[remember picture, overlay]
        {\transparent{0.95}\node [rectangle, rounded corners, fill=LimeGreen, anchor=south west, minimum width=6cm, minimum height=8cm] (box) at (-0.5,-10) (box){};}
        \node[anchor=west, xshift=-2.0cm, yshift=-1cm, text width=4cm] at (box.north){\large \textit{\theeditor}}; 
        \node[anchor=west, xshift=-2.0cm, yshift=-3.5cm, text width=4cm] at (box.north){\huge \thetitle};
        \node[anchor=west, xshift=-2.0cm, yshift=-6cm, text width=4cm] at (box.north){\large \theauthor};


            \eachpageornament \thepage
        \ifnum\value {page}=1 
            \eachpageornament \thepage
    position=current page.north east,




If I rename the package in .tex and include it (trough \include or \input) I got several errors.

I have another doubt about the use of memoir class instead book ... If I use the second instead the first one I got a number of errors regarding references to commands defined in the custom package.

  • 1
    If you load TeX code (extension .sty) via \usepackage then @ will be treated as ordinary letter and can appear in macro names, which is used to defined internal macros that shouldn't be used by the user. If you load the same code (extension .tex) using \input, you will have to surround the \input statement by \makeatletter and \makeatother. If you don't do it, you will get lots of errors and unusable code. – gernot Aug 19 '16 at 7:57
  • 4
    Regarding the difference between \input and \include, see When should I use \input vs. \include? – gernot Aug 19 '16 at 8:02
  • 1
    Of course you get errors when replacing the memoir class by book. Both define document classes for large documents, but the first one is an extension of the second one with many more options; see the memoir documentation for details. You cannot expect that the extensions still work when going back to book. – gernot Aug 19 '16 at 8:10
  • 1
    @weirdgyn see the form in the comment where line breaks appear as spaces, that is also what tex does. \newcommand\foo{ a } is not the same as \newcommand\foo{a} so if you do not want a space in the output do not add spaces or newlines at that position. (or if you do add linebreaks just to indent the source, you need to comment them out with %) – David Carlisle Aug 19 '16 at 9:13
  • 1
    @weirdgyn I'd use .sty so as not having to bother with \makeatletter. But there's not really a big difference, except that \usepackage{defines} will not load again the file, even if issued more than once. – egreg Aug 19 '16 at 9:16

Browse other questions tagged or ask your own question.