I posted a question like this earlier but I'm re-asking because I didn't ask properly before.
I created a .sty
file (preamble.sty
) to help clean up my preamble but I'm having trouble actually using the packages in my document.
Other questions I have followed (in order) without any luck:
-Create a local texmf tree in MiKTeX
My file path to the .sty
file is C:/Users/me/texmf/TeX/LaTeX/PreambleStuff
. I used the MikTeX GUI to add it as a root in the "Settings," then made sure I clicked "Refresh FNDB"
-Where do I place my own .sty or .cls files, to make them available to all my .tex files?
I used the kpsewhich -var-value=TEXMFHOME
command line and the command prompt window did not show any file path, just displayed a new C:\Users\me>
prompt. Does this mean that I don't have a texmf home directory? I also used the command kpsewhich preamble.sty
which shows the correct file path to the file (see file path above).
-https://docs.miktex.org/manual/texfeatures.html#includedirectory
I typedlatex --include-directory=C:/Users/me/texmf/TeX/LaTeX/PreambleStuff preamble.sty
and the command window shows ! LaTeX Error: \usepackage before \documentclass.
See the LaTeX manual or LaTeX Companion for explanation.
The last part raises questions of whether or not I actually wrote my .sty
file correctly, but I am mostly concerned with getting MikTeX to find the file and include it properly in each document. What else can I do or what am I doing wrong?
.sty
file on its own. Your main.tex
file should say something like\documentclass{…}
\usepackage(preamble)
\begin{document}
...
\end{document}
. To get that working, you can putpreamble.sty
in the same directory as your main.tex
file. When that compiles successfully, then go back to figure out where you really want to put the.sty
file so you can use it in other documents as well.