Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

sorry if this question seems off topic, but I had no place to ask it besides here.

I have a big manual I am building in laTeX using either LuaTeX or XelaTeX, doesn't work on pdflaTeX.

It took a lot of crafting to assemble the packages and modifying the fancyhdr, geometry, and tabular environments to make some decent graphics for the manual.

My question is mostly about design... I want to move all those usepackage to an sty file that would allow me to reuse the files. This way I focus on the content and I could create a set of tutorials with the same styling. With some scripting I could create different sets of manuals (print edition, digital edition, tutorial 1,2,3,...,n and html version for docx compatibility).

What do you think of this? Is there some guideline on how to build a proper sty, I am only using packages to generate my styling right now and my newcommand or renewcommand are fairly simple (rarely I use and if expression).

Now I did find some tutorials on sty files, but they do post some very hardcore page formatting to enforce things. And as far as I could see, they don't seem like the place you plaster your usepackages.

share|improve this question
2  
Have you taken a look at the posting Best practice on organising your preamble? –  Mico Mar 12 at 7:24
3  
The preamble of your document is conceptually an anonymous .sty file that you don't load explicitly. Ifit gets big enough and organised enough to make it into a package, you don't need to do anything other than move the whole preamble into mypackage.sty and then load it with \usepackage{mypackage} –  David Carlisle Mar 12 at 9:25
add comment

1 Answer 1

up vote 4 down vote accepted

Ok, I took a look into Best practice on organising your preamble that @Mico recommended and it had exactly the same problem but hard to find. Additionally @David Carlisle explained that if a preamble gets too huge I can move the whole preamble to an sty file.

While a lot of good pointers were made in the other post, after playing a while with the sty I can give a few pointers on the good parts of moving the preamble to an independent sty file:

  • You don't really need all packages This is when if-else logics comes into play. Moving things to an sty file will allow you to add packages smartly to a document depending on an optional variable. For example, I have a few tutorials that don't need the special tables, so the definitions of extra columns, colors, widths and heights is unnecessary.
  • You can create several sty This is an extension to a recommendation made by @Yiannis Lazarides. If we can separate a preamble into different sections (Example: these usepackages are for tables and these for header and footer). The by all means we could create several sty depending on what we add.
  • Problematic stys I said that my manual doesn't run on pdflatex. This is mostly because of fontspec. I did created a map of symbols for my font to use in pdflatex but for big documents it gets messy. With sty creation we could extend this and use pdflatex, a lot of code and installation has to be done to add a font that is ttf but it is possible (though I don't see the purpose right now).
  • The Style gets standarized Which is a good thing.

Disadvantages

Sty files are like a pandora's box for a latex beginner. My first sty was in my masters thesis creation. The advisors would give us the sty like it came directly from olympus. Which it was, someone took the time to craft it. I found over 300 lines of code copy pasted from different styles from other universities.

Conclusion

I thank both of @David Carlisle and @Mico for their input. After reading some parts I think the following milestones are a good way:

  • Create a master sty which includes other sty per thing being edited (tables, headers, images)
  • Remove warnings from preamble in case there are.

This is taking into account that we have a full working preamble right now that's up to 300 lines. I don't think I would start a new document creating an sty.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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