5

I was wanting to write a package for personal use, however I do not know how to create a .sty file on Overleaf. Could someone please suggest to me how I might be able to do this?

Troy W.
  • 151
  • 1
    Welcome. Just change the file ending from tex to sty. But on the other hand, why bother? Simply input your tex file. – Johannes_B Apr 04 '20 at 04:32
  • note it was just by chance I passed here again and saw your edit, you should @ ping me in a comment under my answer if you want me to see the comment. You have the .sty as the main file so overleaf is running that (see my answer where main.tex is first, I just asked in chat if there is an easy way to fix up your project – David Carlisle Apr 04 '20 at 18:59
  • when you started the project it must have made main.tex first, how did you get corrigan.sty to be the main file??? – David Carlisle Apr 04 '20 at 19:02
  • Hi. Tom from Overleaf support here. It indeed appears like that you have the sty file chosen as the main file. You can change the "Main File" in the projects Menu (on top left). If this doesn't help, you can try reaching us at the Overleaf support where we can have a deeper look. – yo' Apr 04 '20 at 19:29
  • @DavidCarlisle, I used upload -> from another project. Although the corrigan.sty is above main.tex when I go to menu, main.tex is chosen as the main file. – Troy W. Apr 05 '20 at 00:35
  • that is simply an error in the tex coding not an overleaf set-up question. I suggest you ask a new question about that. supplying a small complete test as text so people can run it. can't debug a screenshot – David Carlisle Apr 05 '20 at 07:34
  • 1
    oh maybe I can debug a screenshot. You have defined \ccc to take three arguments, all mandatory so must be used as \ccc{one}{two}{three} but you have used it with one optional argument and no mandatory ones \ccc[...] so it is entirely a local package use error and unrelated to your original question. (You could perhaps revert your question edits so that my answer makes sense, that question is I think of general interest for overleaf users, but the question now just shows a coding error in your document and is unrelated to overleaf (or my answer) – David Carlisle Apr 05 '20 at 09:31
  • Thank you for your help @DavidCarlisle. – Troy W. Apr 06 '20 at 04:27

1 Answers1

3

The file/new menu option allows you to specify the filename as mypackage.sty or whatever you want to call the package. It is probably simplest to make the main document a simple test document

\documentclass{article}
\usepackage{mypackage}
\begin{document}
test
\end{document}

so that overleaf has something to run. You can add any specific tests of the commands you are defining to that package as you go along.

main doc enter image description here

package enter image description here

David Carlisle
  • 757,742