Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to generate a .cls file in latex?

Tags:
  1. Jun 17, 2014 #1

    joshmccraney

    User Avatar
    Gold Member

    hey pf!

    i was wondering if any of you knew how to generate a .cls file in latex? in other words, what typeset do i select. for example, some i have now are LaTex, Plain Tex, XeLaTex...

    i'm using TexShop

    thanks!!

    josh
     
  2. jcsd
  3. Jun 17, 2014 #2

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    First things first: What makes you think you need to write your own LaTeX class (suffix=.cls)? Writing a LaTeX class is not an exercise for a novice. You need to cut your teeth on writing packages (suffix=.sty) first.

    A LaTeX document (suffix=.tex) should have one and only one class. This is evinced by the \documentclass[option,option,option,...]{classname} macro at the start of the .tex file. A LaTeX document can use a large number of packages. For example, \usepackage{amsmath,amssymb,amsfonts}, followed by even more usepackage directives.

    If you're package completely takes over the look and feel of the document such as producing a cover page (complete with the fancy company logo), an inside cover page, a signature page, strongly distinguishes between front matter, main matter, and back matter, and redefines things like \chapter and \section, then you might want to think about turning your package into a class. On the other hand, if your package just does those fancy cover pages, it's probably best to leave it as a package.

    If you are trying to take over typesetting, that's generally not a good idea. One of the main points of LaTeX is to separate what you see and what you say. LaTeX is a "What You See Is What You Mean" system rather than a "What You See Is What You Get" system. From what I've seen, the people who struggle most with LaTeX are overly concerned with how things look. Just don't worry about how things look!


    Finally, some suggested reading: LaTeX2ε for class and package writers.
     
  4. Jun 17, 2014 #3

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    When you can understand the magic of \expandafter, \unexpanded, and \noexpand is when you are ready to write a .cls file. For example,
    Code (Text):
    \def\my@elet#1#2#3{%
      \expandafter\expandafter\expandafter\let
      \expandafter\expandafter\expandafter#1%
      \my@csname{#2}{#3}}

    \def\expandsecondarg#1#2#3{%
      \edef\reserved@a{\noexpand#1\noexpand{#2}{#3}}\reserved@a}
     
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to generate a .cls file in latex?
Loading...