2009-02-24 78 views
13

我並不需要對默認文章文檔類進行很多更改。我想要的是:如何在LaTeX中擴展文章文檔類?

  • 重新定義頁邊距(我希望它們在所有頁面上都是相同的,但與默認值不同);
  • 使用標題頁;
  • 加扉頁上多個元素(標題作者日期是不夠的,我想公司和公司標誌是扉頁上爲好);
  • 改變風格部分的,小節subsubsections(我不希望要顯示的號碼,否則 - 他們是很好的)。

也許,在這種情況下可能會有一些軟件包有幫助嗎?

回答

14

有很多包可以幫助你實現你正在尋找的結果。我在下面選擇的軟件包是我喜歡的軟件包,但有多種方法可以實現。

\NeedsTeXFormat{LaTeX2e} 
\ProvidesClass{paulius-article}[2009/02/25 v0.1 Paulius' modified article class] 

% Passes and class options to the underlying article class 
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} 
\ProcessOptions 

% Load LaTeX's article class with the `titlepage' option so that \maketitle creates a title page, not just a title block 
\LoadClass[titlepage]{article} 

% Redefine the page margins 
% TODO: Adjust margins to your liking 
\RequirePackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} 

% Remove the numbers from all the headings (\section, \subsection, etc.) 
\setcounter{secnumdepth}{-1} 

% To modify the heading styles more thoroughly use the titlesec package 
%\RequirePackage{titlesec} 

% Adjust the title page design 
% NOTE: This is the default LaTeX title page -- free free to make it look like whatever you want. 
% TODO: Add company name and logo somewhere in here. 
\newcommand{\maketitlepage}{% 
    \null\vfil 
    \vskip 60\[email protected] 
    \begin{center}% 
    {\LARGE \@title \par}% 
    \vskip 3em% 
    {\large 
    \lineskip .75em% 
     \begin{tabular}[t]{c}% 
     \@author 
     \end{tabular}\par}% 
     \vskip 1.5em% 
    {\large \@date \par}%  % Set date in \large size. 
    \end{center}\par 
    \@thanks 
    \vfil\null% 
    \end{titlepage}% 
} 

% This some before-and-after code that surrounds the title page. It shouldn't need to be modified. 
% I've pulled out the part the actually typesets the title page and placed it in the \maketitlepage command above. 
\renewcommand\maketitle{\begin{titlepage}% 
    \let\footnotesize\small% 
    \let\footnoterule\relax% 
    \let \footnote \thanks% 
    \maketitlepage% 
    \setcounter{footnote}{0}% 
    \global\let\thanks\relax 
    \global\let\maketitle\relax 
    \global\let\@thanks\@empty 
    \global\let\@author\@empty 
    \global\let\@date\@empty 
    \global\let\@title\@empty 
    \global\let\title\relax 
    \global\let\author\relax 
    \global\let\date\relax 
    \global\let\and\relax 
} 

% TODO: If there are any other article modifications required, add them here. 

% That's all, folks! 
\endinput 

您需要閱讀geometry package的文檔以調整邊距。如果您想要修改標題的外觀(除了關閉數字),則可以使用titlesec package

標題頁是LaTeX的默認標題頁。您需要修改它以添加公司名稱和徽標。我從與標題頁關聯的所有其他代碼中分離出「要打印的內容」。您只需要更改\maketitlepage命令。在您的文檔中,使用\maketitle打印標題頁。

\documentclass{paulius-article} 

\title{My New Document Class} 
\author{Paulius} 

\usepackage{lipsum}% provides some filler text 

\begin{document} 
\maketitle% Actually makes a title page 

\section{Section Heading} 
\subsection{Look no numbers!} 
\lipsum[1-10] 

\end{document} 

讓我知道如果我錯過了你的任何要求。

9

你開始

\NeedsTeXFormat{LaTeX2e} 
\ProvidesClass{classname}[2009/02/24] 
\LoadClass{article} 

,之後添加任何自定義。

更新:我建議您閱讀LaTeX2e的課程和包裝編寫者:PDF,HTML。第3節(類或包的結構)中的例子應該是有幫助的。

+0

嗯,我已經得到了這麼多,我甚至有一堆\ setlength {..},但它似乎並沒有爲我工作。你有沒有可以分享的評論很好的擴展?也許是某個地方的鏈接? – Paulius 2009-02-24 14:37:24

+0

我用鏈接更新了我的答案。 – 2009-02-24 14:46:36

+1

良好的聯繫。我睡了一週左右,試圖讓我的畢業論文符合保證金女士的批准... – dmckee 2009-02-24 14:48:00

6

幾個百分點,可能是有趣:

  • 您可以通過正在重置的控制長度一樣\setlength{\textwidth}{6.80in}\setlength{\oddsidemargin}{0.0in}等(\begin{document}之前即}重新定義利潤率頭

  • \section*{...}將會給你未編號的部分。同樣對於\subsection*\subsubsection*。如果你確實使用這個技巧並且也想要工作參考,你可以看看How do I emit the text content of a reference in LaTeX?

  • 你看過titlepage環境嗎?

但也許最重要的是,memoir class可能會給你所有你需要的控制,而沒有任何類的黑客攻擊。檢查出the documentation

或使用Can Berk Güder's suggestion