1

I made my self a myclass.cls file that contains all dependancies i commonly use. That file declares the Paperformat and is laying side by side with my main.tex file. Now after some time and several documents i wrote i have several different such files... So im thinking of outsourcing that file to the user/MYUSER/Library/texmf/tex/latex folder but how can i controll the Paperformat in each document by it self?

main.tex:

%!TEX TS-program = pdfLaTeX
%!TEX encoding = UTF-8
%!BIB program = Bibtex

% Dokument definition
%-------------------------------------------------------------------
\documentclass{myclass}

myclass.cls:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ih-document}
\LoadClass[
10pt,
a4paper
]{article}

is it possible to hand over a value to the class somehow?

Something like:

\documentclass[a4paper]{myclass}
5
  • \PassOptionsToClass, but your question is unclear, in my point of view
    – user31729
    Jan 28, 2017 at 14:51
  • what is unclear?
    – novski
    Jan 28, 2017 at 15:14
  • Read source2e.pdf (from ctan.org/pkg/source2e?lang=en) starting on page 361. Jan 28, 2017 at 15:32
  • uh. that doc has 520 pages and i hardly understand the first... Im only asking for samples how other people work...
    – novski
    Jan 28, 2017 at 17:06
  • Use package geometry to declare the page format.
    – Johannes_B
    Jan 29, 2017 at 13:28

1 Answer 1

3

You should have a look at the clsguide.

\RequirePackage{filecontents}
\begin{filecontents*}{myclass.cls}
% \NeedsTeXFormat{LaTeX2e} not really required nowadays -- doesn't hurt, though
\ProvidesClass{myclass}% the name should match the filename!

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax

\LoadClass[10pt,a4paper]{article}

\end{filecontents*}
\documentclass[11pt,a5paper]{myclass}
\usepackage{blindtext}
\begin{document}

\texttt{\expandafter\meaning\csname f@size\endcsname}

\blinddocument

\end{document}

Remark

Before you run this example file please be aware that

\begin{filecontents*}{myclass.cls}
...
\end{filecontents*}

overwrites any existing myclass.cls without warning!

4
  • Wouldn't it be safer not to load filecontents?
    – cfr
    Feb 1, 2017 at 0:36
  • @cfr probably. But OTOH I don't believe that the real class is really named “myclass” so the risk isn't too high :)
    – cgnieder
    Feb 1, 2017 at 9:01
  • You would be surprised. 'Oh, this is where I put my class name - great! Now, then, ...'
    – cfr
    Feb 2, 2017 at 2:20
  • No I wouldn't, hence my warning. :) but the OP has \ProvidesClass{ih-document} so...
    – cgnieder
    Feb 2, 2017 at 6:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .