1. Document Layout

  • geometry package를 통해 length, margin 등 서식을 설정할 수 있다.
  • 서식은 크게 Page, Layout, Body로 구분한다.
  • Head와 Foot은 Body안으로 포함시킬수도 있고, 밖으로 빼낼 수도 있다.

1) Page

  • 보통은 a4paper, a5paper, ...와 같이 용지의 종류로 표현한다.
  • 길이 설정 : pagesize = {paperwidth, paperheight}
  • margin, length 한번에 설정
    • hdivide = {left, textwidth, right}
    • vdivide = {top, textheight, bottom}
  • twoside인 경우(ex. book), bindingoffset을 설정할 수 있다.
width = bindingoffset + left + textwidth + right

2) Layout

  • 길이 설정 : layoutsize = {layoutwidth, layoutheight}
  • 위치 설정 : layoutoffset = {layouthoffset, layoutvoffset}
    layout이 왼쪽 위에 딱 붙어 있다고 생각했을 때 오른쪽, 아래로 얼마나 이동할 것인가를 의미한다.

3) Total Body

  • 왼쪽 : Default
  • 가운데 : includeheadfoot option
    head만 body로 추가, includehead / foot만 body로 추가, includefoot
  • 오른쪽 : includeall option
    includehead + includefoot + includemp

  • 길이 설정(body) : body = {textwidth, textheight}
  • 길이 설정(total body) : total = {width, height}
width = textwidth + (marginparsep + marginparwidth)
height = textheight + (headheight + headsep + footskip)

4) Examples

LaTeX 코드 보기
\documentclass{report}
\usepackage[showframe, a4paper,
            hmargin = 0.5in, vmargin = 1in,
            headheight = 1cm, headsep = 10pt, 
            includemp, marginparwidth = 4cm, marginparsep = 10pt]{geometry}
\usepackage{lipsum}

\pagestyle{empty}

\begin{document}

\vspace*{10cm}
\centering 
\Huge{Customizing Page Size}

\end{document}

2. Header and Footer

  • \pagestyle{}을 통해 스타일을 지정할 수 있다.
    styles : empty, headings, myheadings, fancy(fancyhdr package)
  • one side : L, C, R로 위치 지정
  • two side : even(LE,CE,RE), odd(LO,CO,RE)로 위치 지정

one side인 경우

1) 기본 용어

command description
\rightmark book이라고 생각했을 때, odd page(오른쪽 페이지)에서 left에 있는 자리에 \sectionmark가 출력된다.
\leftmark book이라고 생각했을 때, even page(왼쪽 페이지)에서 right에 있는 자리에 \chaptermark가 출력된다.
\thepage 페이지 번호를 지정
\pagenumbering{}을 통해 페이지 page style을 지정할 수 있다.
(arabic, roman, Roman, alph, Alph)
  • Custom(Using fancyhdr package)
      \pagestyle{fancy}
    
      % clear header and footer
      \fancyhead{}     
      \fancyfoot{}     
    
      % custom header and footer 
      fancyhead['pos']{'content'}
      fancyfoot['pos']{'content'}
    
      % custom mark 
      \renewcommand{\chaptermark}{\markboth{#1}{}}
      \renewcommand{\sectionmark}{\markright{#1}{}}
    
      % custom rule 
      \renewcommand{\headrulewidth}{'length'}
      \renewcommand{\footrulewidth}{'length'}
    
      \renewcommand{\headrule}{'content'}
      \renewcommand{\footrule}{'content'}
    
      % custom margin 
      \setlength{'margin'}{'length'}
    

2) Custom (1) - change mark

  • default로 chapter, section이 uppercase와 italic으로 표현된다.
  • uppercase만 바꾸고 싶다면 \nouppercase를 통해 간단히 바꿀 수 있다.
  • default
    \renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\chaptername\ \thechapter. #1}}{}}
    \renewcommand{\sectionmark}[1]{\markright{\MakeUppercase{\thesection. #1}}{}}
    
Example1 - LaTeX 코드 보기
\fancyhead[R]{\nouppercase{\leftmark}}
\fancyhead[L]{\nouppercase{\rightmark}}

Example2 - LaTeX 코드 보기
\pagestyle{fancy}
\fancyhead[R]{\textsf{\leftmark}}
\fancyhead[L]{\textsf{\rightmark}}

\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter\ -\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{Section\ \thesection\ -\ #1}{}}

2) Custom (1) - change rule

  • \headrule(\footrule) 또는 \headrulewidth(\footrulewidth)로 custom할 수 있다.(둘 다 동시에는 안 됨)
\renewcommand{\headrule}{'바꿀 내용'}
\renewcommand{\footrule}{'바꿀 내용'}

\renewcommand{\headrulewidth}{'길이'}
\renewcommand{\footrulewidth}{'길이'}
Example1 - LaTeX 코드 보기
\renewcommand{\headrulewidth}{2pt}

Example2 - LaTeX 코드 보기
\renewcommand{\footrule}{\dotfill}

Example3 - LaTeX 코드 보기
\renewcommand{\headrule}{\hrulefill \parbox[c]{2cm}{\vspace{5pt}\centering My Book} \hrulefill}

3) Custom (2) - define pagestyle

\fancypagestyle{'pagestyle name'}['base style]{'contents'}
Example - LaTeX 코드 보기
\documentclass{book}
\usepackage[margin=1in,bindingoffset=1in]{geometry}
\usepackage{lipsum}
\usepackage{fancyhdr}

\fancypagestyle{mystyle}[fancy]{
    % clear header and footer
    \fancyhead{}
    \fancyfoot{}
    
    % custom header and footer
    \fancyfoot[LE,RO]{\thepage}
    \fancyfoot[RE]{\leftmark}
    \fancyfoot[LO]{\rightmark}
    
    % custom rule
    \renewcommand{\headrule}{\hrulefill \; \textit{\MakeUppercase{Title Name}} \; \hrulefill}
    \renewcommand{\footrulewidth}{0.4pt}
}

\pagestyle{mystyle}

\begin{document}

\chapter{Chapter Name}
\section{Section Name}
\lipsum[1-3]

\newpage
\lipsum[1-3]

\newpage
\lipsum[1-3]

\end{document}

댓글남기기