代码之家  ›  专栏  ›  技术社区  ›  Paulius

如何在LaTeX中扩展文章文档类?

  •  15
  • Paulius  · 技术社区  · 16 年前

    • 使用标题页;
    • , 作者 对我来说还不够,我想 公司 标志 也要出现在标题页上);
    • 章节 , 分节 (我不想显示这些数字,否则——它们很好)。

    3 回复  |  直到 16 年前
        1
  •  15
  •   godbyk    16 年前

    有许多软件包可以帮助您实现所需的结果。我在下面选择的软件包是我喜欢的,但有不止一种方法可以做到这一点。

    \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\p@
      \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 如果你想修改标题的外观(除了关闭数字),可以使用。

    \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}
    

        2
  •  10
  •   Can Berk Güder Pugalmuni    16 年前

    你从

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

    并在之后添加任何自定义项。

    更新: 我建议你阅读LaTeX2e的类和包编写程序: PDF , HTML

        3
  •  6
  •   Community CDub    8 年前

    有几点可能很有趣:

    • 您可以重新定义标题中的边距(即之前 \begin{document} }通过重置控制长度,如 \setlength{\textwidth}{6.80in} , \setlength{\oddsidemargin}{0.0in}

    • \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 .