Create latex style files

10,595

There's not much special about sty or cls files; they're just LaTeX files with a special purpose and another file extension. You could use any editor to write them, preferably your favourite LaTeX editor. I'm not aware of any dedicated editor just for style and class files; and I'm not really sure how the WYSIWYG concept could be applied to styles/classes anyway.

If you just want to collect some LaTeX settings/definitions in a common file, use your favourite editor to write them (or copy them from a document where they're already working). Insert \ProvidesFile{packagename} at the beginning of the file. Save it with a .sty extension in a place where TeX can find it. Then you can invoke \usepackage{packagename} in your LaTeX documents, and your package will be loaded right away.

Here's an example where I put together my settings for letters with the scrlettr class:

\ProvidesFile{FJ-Brief-CB}

\name{Florian Jenn}
\signature{\bigskip Florian Jenn}

\address{Some street 123 \quad 03\,044 Cottbus}

\subjecton

% and so on...

For “real” packages, consult “LaTeX2e for class and package writers” at http://www.latex-project.org/guides/clsguide.pdf, as already mentioned by user33872. Additionally, there's a short overview by Joseph Wright: http://www.texdev.net/2009/10/05/the-dtx-format/. Basically, you'll have to write a doc (dtx) file, from which the sty and documentation files can be generated.

Any editors that can be used for LaTeX should do; however, it's nice to have explicit dtx (docTeX) support. AFAIK, Emacs (docTeX mode in AUCTeX) or WinEdt (see http://www.winedt.org/Config/modes/DTX.php) have it. I've had a quick look at Kile and TeXmaker – they don't have explicit modes (editing dtx is still possible, just not so nice). See also Joseph Wright's notes on editing dtx: http://www.texdev.net/2009/10/11/working-with-dtx-files/

Share:
10,595

Related videos on Youtube

PeterJCLaw
Author by

PeterJCLaw

Updated on September 17, 2022

Comments

  • PeterJCLaw
    PeterJCLaw over 1 year

    What (WYSIWYG) tools are there for creating LaTeX style files?

    What guides exist on how to build them by hand?

    Could you recommend some?

    =EDIT=

    To clarify - I'm looking for something that will give a .sty or .cls file or similar (not entirely sure which of these does what, I'm relatively new to LaTeX) that I can use across a number of different documents, potentially with a number of templates.