Questions tagged [documentclass-writing]
{documentclass-writing} is about writing document classes. If your question is about choosing, installing, or using document classes, choose {documentclass} instead.
473
questions
215
votes
6
answers
43k
views
Where do I start LaTeX programming?
I'm interested in writing packages for TeX/LaTeX/XeLaTeX. I googled around, but all I found was guides or tutorials about how to prepare documents using LaTeX. I want to know how LaTeX works and how ...
162
votes
7
answers
82k
views
Style/class tutorials
What are some good tutorials on writing custom styles (classes) that clearly explain commands used and some of the features that TeX has to offer in the way of styles?
91
votes
5
answers
46k
views
A cookbook in LaTeX?
I am interested in making a cookbook in LaTeX. Each page will contain a recipe, including ingredients, instructions, and a photo of the finished food. Has this been done previously? Where do I ...
72
votes
4
answers
3k
views
What is good practice when preparing a package for CTAN?
I'm thinking of submitting a package to CTAN, and would like some hints which will help keep the path as smooth as possible for me, the CTAN administators, and the final users.
Please tell me what I ...
65
votes
4
answers
14k
views
Reference guide to begin writing a class and/or a package
Once a LaTeX user gets more and more skilled, and writes his/her own code, the question "Should I make a package (or a class) out of it?" will probably arise.
My question is (you catch me: I'm one of ...
60
votes
3
answers
17k
views
\newcommand vs \DeclareRobustCommand
I sort of understand the difference between the two. But that's not what I'm interested in—I just want to know, which one should I use? In general, when I'm creating commands in a package or class, ...
44
votes
1
answer
3k
views
Macro naming best practice?
Is there a preferred or generally accepted idiom for naming user defined macros? I notice that in the change from Tufte 3.5.0 to 3.5.2, for example, the names of the debugging macros have change, for ...
39
votes
2
answers
863
views
When or why should I use %% as opposed to %?
I've noticed that many (all?) style and class files have "documentation blocks" with a double comment character at the beginning of the line,
%% like so
instead of the usual style of comments,
% ...
39
votes
2
answers
84k
views
how to create a template or document class for latex?
I need to write a document class or template, as for an article, letter, etc. Is there software for this? How do I set it up so that anyone can use my class just like \documentclass{article}?
36
votes
4
answers
14k
views
How to write a LaTeX class file for my thesis
I want to design a new LaTeX for my college thesis, so that all students could use it. I have decent understanding of how LaTeX works.
I am looking for some nice article explaining how to write a ...
32
votes
7
answers
3k
views
What's a good editor for (La)TeX programming?
I've found several questions about editors for writing LaTeX documents ( LaTeX Editors/IDEs seems to be the definitive one). But I'd like to know which editors are out there that help you develop ...
29
votes
4
answers
3k
views
Creating a class file vs using packages
In my limited LaTeX experience, I've always found that I can accomplish what I want by just using the relevant set of packages, even for more complex formatting. If I were to try and create a ...
25
votes
6
answers
3k
views
Holiday present-ation vs. content contest
Need something to do during holiday break? Enter this holiday contest!
Your challenge is to write a happyholidays class that will compile the following input document in the most creative, ...
25
votes
3
answers
3k
views
Customizing LaTeX - create a document class or a package?
Are there general rules for when to create a document class vs. creating a package to customize LaTeX? Does one have benefits over the other?
My specific need is to create a customized page layout, ...
25
votes
1
answer
3k
views
How do I document my style files?
I have many style files (and one or two class files) that I've written in my local texmf tree. Most were simple things that got me out of some trouble and which I put in to a style file in case I ...
23
votes
1
answer
10k
views
Creating new class file: Where to start?
Recently, a journal I have some editorial involvement with has decided that for its 'rapid publication' outlet, it will no longer accept submissions where LaTeX has been used to format the document. ...
22
votes
1
answer
2k
views
When to use ".sty" extension and when to use ".def"
I'm new to this forum and a recent LaTeX user. I state that, before posting here, I searched all the web through, but I was not succeeded to solve a doubt.
I'm writing my own class (myclass.cls), ...
21
votes
3
answers
1k
views
Write new package with LaTeX2e or LaTeX3
I’m planning to create a package and I wonder if it’s better do do this with LaTeX3 syntax or the „old“ LaTeX2e, which is the one I know.
Will LaTeX2e packages be supported by LaTeX3?
I can give ...
21
votes
3
answers
2k
views
what TeX package(s) should I use for a Church Bulletin
I create Sunday Bulletins (aka service leaflets) for an Episcopal Church each week. Currently, I use the MS Publisher (PITA) I also do some web design using Ruby. While a physics undergrad, I ...
18
votes
3
answers
735
views
Advantages of a custom class over a package and environment
What are the advantages/disadvantages of defining a class over a package and environment?
I have recently started to clean up some of the cruft in the preamble of my letters. The simplest solution ...
18
votes
3
answers
18k
views
Possibility to pass options to packages
I am searching for a possibility to give additional options to another package.
I have tried it with \PassOptionsToPackage.
My idea was that I can use something like \documentclass[hyperref={...
18
votes
1
answer
363
views
When should I upload my new style?
I've been working lately in a new style for my university, which is heavily influenced by a pre-existing style (feupteses). However, feupteses was never meant for PhD dissertations, so I decided to ...
17
votes
3
answers
3k
views
Macro for Declaring Variables in Class Files
I'm designing a new LaTeX class, and trying to write a convenient helper command for declaring new 'variables' for use in the class.
Specifically, say I want to use a variable called \foo. I'd like ...
17
votes
2
answers
1k
views
Defining a wrapper class for a set of document classes
Until now, I have been collecting my "frequently used packages", custom macros, and configurations in a personal style file. However, some of those configurations depend on the use of one of the KOMA-...
16
votes
2
answers
13k
views
Where can I find the article.cls class file of texlive-2016 on my pc?
I want to study the source code of article.cls so I can create macros of my own. If anybody can tell me the location of article.cls document class file, that will be highly appreciated.
16
votes
1
answer
206
views
What are the established methods for filing and tracking bugs in packages?
My particular concern is in finding Polyglossia's author, Francois Charette, whose email address I could not find in Google. However, I think the issue is much more general.
If you encounter a bug in ...
15
votes
2
answers
10k
views
ProcessOptions and ProcessKeyvalOptions
\ProcessOptions and \ProcessKeyvalOptions
Which comes first? Does it matter?
\ProcessOptions\relax or \ProcessOptions*
What's the difference? Apparently for keyval there is only the starred version. ...
15
votes
3
answers
4k
views
How to write a class that accepts an optional key-value pair?
a user-defined class:
\ProvidesClass{preview}[2012/12/15 v 0.01 class for creating a tight PSTricks diagram]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\...
15
votes
1
answer
219
views
Should I use packages when writing a class
I am trying to write a class based on the book class (a thesis class for my department).
My question is: is it bad for some reason (or, is it considered bad) to use packages in the class files ...
15
votes
1
answer
2k
views
How does "missing \begin{document}" work?
I would like to know how does LaTeX invoke the error Missing \begin{document}. I would like to reproduce it in the sense of the following MWE (it will become a part of my own document class):
\...
14
votes
3
answers
6k
views
LaTeX document without \documentclass
I need to create a really simple document template for other people to fill in and compile (e.g., they need to provide a name and email address). I could distribute it as a .cls file and a template ....
14
votes
2
answers
22k
views
LaTeX "Variables" - \@varname
I'm currently in the process of writing my first document class file (a personalized resume class), and I want to get a better understanding of what exactly I'm doing. So, right now I'm setting up ...
14
votes
3
answers
2k
views
How can I word-wrap LaTeX warning/error output?
This question led to a new package:
hardwrap
In writing error messages and warnings for a package/class, I find it a pain to manually insert \MessageBreaks so that words don't get cruelly bisected ...
14
votes
2
answers
18k
views
How to set default font size in latex cls file?
I am using a custom LaTeX document class for my thesis which is derived from the report class. I'd like to set the default size of the font to 12pt, and still have the option to change it (to 10pt) ...
13
votes
7
answers
2k
views
Remove leading zeroes from an integer
In the documentclass I am writing, the user will input an integer such as \lessonnumber as an integer with possibly a number of leading zeroes, e.g. 4 as 04. At some places in the document I will need ...
13
votes
2
answers
413
views
How to detect whether "I'm on arXiv.org"?
I write a class. I'm interested in having a different page headers (and eventually make some other small differences) based on whether the class is used on the site arXiv.org or not. Minimal example ...
13
votes
1
answer
4k
views
Changing the default options of a document class?
I would like to define some base-class.cls, with some options and their defaults, and then provide some mechanism so that other derived classes can reuse the existing options and change the defaults. ...
12
votes
1
answer
406
views
Is TeX necessary if using LaTeX?
I have been using LaTeX for a little over two years now. I mostly use it to prepare homework solutions in mathematics and engineering coursework. I also use it to document my research and writing some ...
12
votes
2
answers
275
views
The following code compiles without error. How can I change that?
Unlike most questions on this site, my problem is that my code compiles without error and I do not want it to.
I want to be able the check whether \command is defined and to do something if it is ...
12
votes
2
answers
713
views
What is the best practice for arithmetic operations specially for package/class writing?
There are some possibilities to execute arithmetic operations inside a package or class.
TeX
TeX supports \advance, \multiply or \divide to execute arithmetic operations. However the syntax is more ...
12
votes
1
answer
2k
views
Using of \usetikzlibrary in an expl3 package fails
In the example below I provided a small test package mytestpackage.sty which uses the syntax of expl3.
If I use the command \usetikzlibrary inside the package I will get the error:
Runaway argument?
...
12
votes
1
answer
313
views
What happens when a package patches another, and then the original one is reloaded?
I'm in the process of cleaning up my class file and I'm unclear as for the proper order of some lines. For example (replacing \RequirePackage with \usepackage and putting this in a MWE):
\...
12
votes
2
answers
2k
views
What is the difference between \@@par and \par?
In LaTeX internal code I came accross \@@par. How is this different from \par or \newline. When should I use \@@par if I am writing a package or class file?
In general, there are so many other ...
11
votes
3
answers
545
views
When writing a class/package, how can I run code if/when another package is loaded? [duplicate]
I'm writing a thesis class file and I'd like to delay the running of code to after a specific package is loaded:
\AtEndOfOtherPackage{listings}{%
\lstset{language=Python}}
Is there a command that ...
11
votes
2
answers
19k
views
How to adjust the size and placement of chapter heading in report class
How could I adjust the size and placement of chapter heading in my custom class? I am using report class as my base. When I used titlesec package inside my custom class, it threw error
! Package ...
11
votes
1
answer
1k
views
\PassOptionsToClass does not work
I am trying to create my own class, inheriting from extarticle.
I want to still be able to use the options of this class, so I found a way to do it in most of the docs I read :
\DeclareOption*{\...
11
votes
3
answers
1k
views
When/How should a class load biblatex
I would like to write a custom class that loads the biblatex package, but I am having trouble with option clashes. For example, the following MWE gives me an error
% arara: pdflatex
% arara: biber
% ...
11
votes
1
answer
2k
views
Write a class with language dependent strings
I am unable to make my class strings language dependent using babel.
I have the following minimal example:
file test-babel.cls
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{test-babel}[2012/...
11
votes
1
answer
1k
views
What is the minimal codes to create my own \documentclass derived from LaTeX's book?
I want to invoke my document class as follows:
\documentclass[cymk,dvips,dvipsnames]{mybook}
Internally mybook.cls includes my own packages such as mytables.sty, mypstricks.sty, etc.
What is the ...
11
votes
1
answer
647
views
Processing document class options with l3keys
How can I parse (that is, access) the entire option list given to the current document class with l3keys?
This would obviously need some sort of
\keys_define:nn { document-class-?? }
{
default ....