2010-09-13 65 views

回答

6

您可以將您的導言代碼放入.cls文件中,然後使用\documentclass{mydocstyle}加載它。您.cls文件將是這樣的:

% Declare that this document class file requires at least LaTeX version 2e. 
\NeedsTeXFormat{LaTeX2e} 

% Provide the name of your document class, the date it was last updated, and a comment about what it's used for 
\ProvidesClass{mydocstyle}[2010/09/13 Bluetulip's custom LaTeX document style] 

% We'll pass any document class options along to the underlying class 
\DeclareOption*{% 
    \PassOptionsToClass{\CurrentOption}{article}% or book or whatever 
} 

% Now we'll execute any options passed in 
\ProcessOptions\relax 

% Instead of defining each and every little detail required to create a new document class, 
% you can base your class on an existing document class. 
\LoadClass{article}% or book or whatever you class is closest to 

% Now paste your code from the preamble here. 
% Replace \usepackage with \RequirePackage. (The syntax for both commands is the same.) 

% Finally, we'll use \endinput to indicate that LaTeX can stop reading this file. LaTeX will ignore anything after this line. 
\endinput 

注意,文檔類文件可以變得更加複雜,(如果你想包括像\documentclass[option]{mydocstyle}等選項),但是這個基本格式應該讓你開始。

將文件保存爲mydocstyle.cls,並將其與.tex文件放在當前目錄中。你可以看看LaTeX2e for class and package writers guide。它會更詳細地介紹這一點。

+0

感謝您的指針,這足以讓我開始。在這種情況下,提及命令\ LoadClass [options] {article}也會有所幫助。 – Bluetulip 2010-09-14 07:54:20

+0

哎呀!我的意思是忘記了。我已經將其添加到我的回答中,因此對其他人更有幫助。我還添加了一些代碼來處理傳遞給文檔類的選項。 – godbyk 2010-09-15 17:41:52

相關問題