How to generate a .cls file in latex?

  • LaTeX
  • Thread starter member 428835
  • Start date
  • Tags
    File Latex
In summary, the conversation discusses the process of generating a .cls file in LaTeX and the differences between a class and a package. The expert advises against writing a class for beginners and suggests starting with packages instead. They also recommend further reading on LaTeX2ε for class and package writers.
  • #1
member 428835
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
 
Physics news on Phys.org
  • #2
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.
 
  • #3
When you can understand the magic of \expandafter, \unexpanded, and \noexpand is when you are ready to write a .cls file. For example,
Code:
\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}
 
  • Like
Likes 1 person

What is a .cls file in latex and why is it important?

A .cls file in latex is a class file that contains the document class and formatting information for a specific type of document. It is important because it helps to maintain consistency and structure in the document layout and formatting, making it easier to create professional-looking documents.

How do I generate a .cls file in latex?

To generate a .cls file in latex, you can use the command "latex makecls classname" in the command prompt. This will create a .cls file with the specified class name.

Can I customize the contents of a .cls file in latex?

Yes, you can customize the contents of a .cls file in latex by editing the class file directly. However, it is recommended to create a new file with a different name rather than modifying an existing .cls file.

What are the common elements included in a .cls file in latex?

A .cls file in latex typically includes the document class, formatting specifications, document layout, and any additional packages or commands needed for the document. It may also contain specific instructions for creating a title page, table of contents, and other elements.

Can I use a .cls file in latex for different types of documents?

Yes, you can use a .cls file in latex for different types of documents as long as the class file contains the necessary formatting and layout specifications for that document type. However, it is recommended to create a separate .cls file for each type of document for better organization and customization.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
23
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
907
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
385
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
20
Views
3K
Back
Top