2012年7月24日火曜日

LaTeX で余白などなどの設定をする

更新ました(LaTeXで余白などなどの設定をする2).
---
何やら学習成果レポートなるものを提出する必要があるようで,
LaTeX 使って書こうと思っていたのだけれども,
行数の指定やら余白の指定で手間取ったので
今後同じ手間をかけないような備忘録的な,メモ.


横余白
---
% A4(210mm)
\setlength{\textwidth}{145truemm}
\setlength{\fullwidth}{\textwidth}
\setlength{\oddsidemargin}{35truemm}
\addtolength{\oddsidemargin}{-1truein}
---
左余白35mm,右余白30mm と仮定.
左余白(\oddsidemargin)と本文(\textwidth,210-35-30=145mm)を
指定すれば右余白は残った幅(210-35-145=30mm)ということになる.

縦余白
---
% A4(294mm)
\setlength{\textheight}{244truemm}
\setlength{\headheight}{0pt}
\setlength{\headsep}{25truemm}
\setlength{\footskip}{15truemm}
\addtolength{\topmargin}{-1truein}
---
上余白25mm,下余白25mm と仮定.
上余白(\headsep)と本文(\textheight,294-25-25=244mm)だけでなく,
ページ番号挿入位置(\footskip)を指定する必要がある.

もちろん,ヘッダーフッター入れる時はもっと細かくなる.

文字数&行数
---
\renewcommand{\headfont}{\bfseries}
\makeatletter
\def\mojiparline#1{
    \newcounter{mpl}
    \setcounter{mpl}{#1}
    \@tempdima=\linewidth
    \advance\@tempdima by-\value{mpl}zw
    \addtocounter{mpl}{-1}
    \divide\@tempdima by \value{mpl}
    \advance\kanjiskip by\@tempdima
    \advance\parindent by\@tempdima
}
\makeatother
\def\linesparpage#1{
    \baselineskip=\textheight
    \divide\baselineskip by #1
}
---
これをプリアンブル部に書いて,

---
\mojiparline{40}
\linesparpage{30}
---
とbody部に書けばいい.
この場合,40文字30行.

表紙画像
---
\enlargethispage{\paperwidth}
\thispagestyle{empty}
\vspace*{-1truein}
\vspace*{-\topmargin}
\vspace*{-\headheight}
\vspace*{-\headsep}
\vspace*{-\topskip}
\noindent\hspace*{-1in}\hspace*{-\oddsidemargin}
\includegraphics{top_page.eps}
---
LaTeX だとなかなかWord とかのように表紙を作れないので
いっそのこと画像にして貼っちゃおう!とあったので
210mm*294mm の画像(top_page.eps)を用意した.

注意点は\documentclassでフォントサイズを変えると
なんか画像の大きさが変わってしまうこと.
そのためフォントサイズの変更はbody部に\large とか
単体で書いて対応.

まとめ
---
\documentclass[a4paper]{jsarticle}
\usepackage[dvips]{graphicx}

\setlength{\textwidth}{145truemm}
\setlength{\fullwidth}{\textwidth}
\setlength{\oddsidemargin}{35truemm}
\addtolength{\oddsidemargin}{-1truein}

\setlength{\textheight}{244truemm}
\setlength{\headheight}{0pt}
\setlength{\headsep}{25truemm}
\setlength{\footskip}{15truemm}
\addtolength{\topmargin}{-1truein}

\renewcommand{\headfont}{\bfseries}
\makeatletter
\def\mojiparline#1{
    \newcounter{mpl}
    \setcounter{mpl}{#1}
    \@tempdima=\linewidth
    \advance\@tempdima by-\value{mpl}zw
    \addtocounter{mpl}{-1}
    \divide\@tempdima by \value{mpl}
    \advance\kanjiskip by\@tempdima
    \advance\parindent by\@tempdima
}
\makeatother
\def\linesparpage#1{
    \baselineskip=\textheight
    \divide\baselineskip by #1
}

\begin{document}
\large

\enlargethispage{\paperwidth}
\thispagestyle{empty}
\vspace*{-1truein}
\vspace*{-\topmargin}
\vspace*{-\headheight}
\vspace*{-\headsep}
\vspace*{-\topskip}
\noindent\hspace*{-1in}\hspace*{-\oddsidemargin}
\includegraphics{top_page.eps}

\mojiparline{40}
\linesparpage{30}
---

参考URL:いっぱい

0 件のコメント:

コメントを投稿