
LaTeX에서 나만의 문서 클래스를 만들고 있는데 내 클래스를 사용할 때 이 제목이 자동으로 표시되도록 하려면 어떻게 해야 하는지에 대한 문제가 있습니다.
이렇게 코딩해야 할까요?
\AtBeginDocument{%
\vspace*{-0.4in}\noindent
{\Large\bfseries School name here} \\
{\large\sffamily college name here} \\[0.2in]
{\Large\sffamily department name here} \\[0.2in]
{\Large\sffamily Subjectcode, subject name here} \\[0.2in]
{\Large\sffamily school year here} \\[0.2in]
\vspace{0.2in}
}
답변1
예. 그런 것.
귀하의 프로필을 검색한 결과 귀하가 자신의 클래스나 패키지를 사용할 때마다 헤더가 자동으로 로드되도록 자신만의 클래스나 패키지를 작성하는 데 관심이 있을 것이라는 것을 알았습니다. 문제가 어디서 발생하는지 알 수 있습니다. 시험이나 그와 유사한 것(학교 시험지 템플릿 등)을 만들고 싶을 때마다 게시한 것과 같은 헤더를 입력해야 하는 시간을 줄이고 싶을 수도 있습니다.
이를 수행하는 데는 여러 가지 옵션이 있으며 저는 두 가지를 나열합니다.
1. 자주 사용하는 모든 코드를 별도의 파일에 넣은 다음복사그리고반죽필요에 따라.
2. 패키지 또는 클래스 파일 생성이미 도움을 받았지만 해당 게시물을 알려드리고 싶습니다.스타일/클래스 튜토리얼. 관련 질문도 있어요\documentclass{letter}에 이미지 헤더를 넣습니다..
옵션 2와 여기에 게시한 링크에 있는 링크를 사용하여 나만의 문서 클래스를 만들었습니다.자동화하다수업 시험과 학교 메모의 첫 번째 페이지에는 학교 헤더가 포함되고 다른 페이지에는 포함되지 않습니다. 특정 문제의 경우 다음 내용이 포함된 클래스 파일을 가질 수 있습니다.
헤더를 손상시키지 않고 첫 번째 페이지에 헤더가 나타나도록 하려면 다음과 같이 할 수 있습니다.
\ProvidesClass{myclass}[2012/09/03 version 0.01 My exam class] \NeedsTeXFormat{LaTeX2e}[1996/06/01]% \PassOptionsToClass{\CurrentOption}{article} \ProcessOptions \relax \LoadClass{article} \RequirePackage[margin=1in]{geometry} \AtBeginDocument{ \begin{center} \sffamily {\Large\textbf{School Name}} {\large\textbf{Name of College}}\\ {\large Name of Department}\\ {\large Subject code, subject name}\\ {\large SY 2012-2013} \end{center} \noindent Name: \makebox[3in]{\hrulefill} \hfill Section: \makebox[2in]{\hrulefill}\\ } \endinput
공간을 절약하기 위해 위쪽 여백을 사용하려면 다음과 같이 할 수 있습니다.
\ProvidesClass{myclass}[2012/09/03 version 0.01 My exam class] \NeedsTeXFormat{LaTeX2e}[1996/06/01]% \PassOptionsToClass{\CurrentOption}{article} \ProcessOptions \relax \LoadClass{article} \RequirePackage[margin=1in]{geometry} \RequirePackage{fancyhdr} %% This sets the header of the first page of the letter \fancypagestyle{firstpage}{% \fancyhf{} % clear all six fields \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} \fancyhead[C]{ \parbox[t][]{4in}{ \centering \sffamily {\Large\textbf{School Name}}\\ {\large\textbf{Name of College}}\\ {\large Name of Department}\\ {\large Subject code, subject name}\\ {\large SY 2012-2013} }} } \fancypagestyle{followingpage}{% \fancyhf{} % clear all six fields \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} } \pagestyle{followingpage} % followingpage is the default page style \AtBeginDocument{\thispagestyle{firstpage} % the page style on the first page \geometry{headheight=1in,headsep=0.1in} \noindent Name: \makebox[3in]{\hrulefill} \hfill Section: \makebox[2in]{\hrulefill}\\ } \endinput
업데이트: 9월 4일.다음은 여기에 게시한 클래스를 테스트하기 위한 MWE입니다.
\documentclass{myclass}
\usepackage{lipsum}
\begin{document}
\lipsum[1-20]
\end{document}
아래는 제가 게시한 두 번째 수업의 결과입니다. 필요에 맞게 크기를 조정할 수 있지만 아이디어는 있습니다.