Skip to content

Instantly share code, notes, and snippets.

@y-yu
Last active August 29, 2015 13:58
Show Gist options
  • Save y-yu/10393602 to your computer and use it in GitHub Desktop.
Save y-yu/10393602 to your computer and use it in GitHub Desktop.
\linespace{\section{見出し}} % 自動で何行取るのか計算される
\linespace[3]{\section{見出し}} % 何行取るか手動で入れる
\makeatletter
\def\linespace{%
\@ifnextchar[\@linespace\@linespace@auto}
\newcount\c@linespace
\long\def\@linespace@auto#1{%
\c@linespace = 1
\setbox\@tempboxa\vbox{#1}%
\setlength\@tempdima{\ht\@tempboxa}%
\addtolength\@tempdima{\dp\@tempboxa}%
\def\@rec{%
\setlength\@tempdimb\Cvs
\multiply\@tempdimb\c@linespace
\ifdim \@tempdimb>\@tempdima
\def\@k{\@linespace[\c@linespace]{\box\@tempboxa}}%
\else
\advance\c@linespace1
\def\@k{\@rec}%
\fi
\@k}%
\@rec
}
\long\def\@linespace[#1]#2{%
\par
\setlength\@tempdima\Cvs
\multiply\@tempdima#1
\advance\@tempdima-\Cvs
\advance\@tempdima-\Cht
\advance\@tempdima\Cdp
\setbox\z@\vbox{#2}%
\advance\@tempdima-\ht\z@
\advance\@tempdima-\dp\z@
\vspace{\ht\z@}%
\vspace{\dp\z@}%
\allowbreak
\vspace{-\ht\z@}%
\vspace{-\dp\z@}%
\vtop to\z@{%
\vskip.5\@tempdima
\box\z@\vss}\quad
\setlength\@tempdima\Cvs
\multiply\@tempdima#1
\advance\@tempdima-2\Cvs
\vspace\@tempdima
\par\nobreak}
\makeatother
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment