最終更新:2014-04-22 (火) 04:36:27 (1575d)

TeXマクロ

年賀状(未完成)

\documentclass[uplatex]{jsarticle}
% 紙面設定
\pagestyle{empty}
\setlength\unitlength{1mm}
\parindent = 0pt
\AtBeginDvi{\special{papersize=100mm,148mm}}
\paperwidth = 100mm
\paperheight = 148mm
\textwidth = 100mm
\textheight = 148mm
\hoffset = -1in
\voffset = -1in
\oddsidemargin = 0mm
\footskip = 0mm
\headheight = 0mm
\headsep = 0mm
\marginparwidth = 0mm
\marginparsep = 0mm
% コマンド定義
\makeatletter
% 
\newif\if@nng@tempsw
\newbox\nng@tempbox
% 左余白
\def\lmargin#1{\setlength\evensidemargin{#1}\oddsidemargin=\evensidemargin}
% 上余白
\def\tmargin#1{\setlength\topmargin{#1}}
% 敬称
\def\Keisyo#1{\gdef\nng@keisyo{#1}}
\global\let\nng@keisyo\relax

\newenvironment{atena}{%
  \def\Zip##1{\def\nng@zip{##1}}% 郵便番号
  \def\Address##1{\def\nng@address{##1}}% 住所 1
  \def\SubAddress##1{\def\nng@subaddress{##1}}% 住所 2
  \def\Name##1##2{\def\nng@myoji{##1}\def\nng@namae{##2}}% 宛先
  \def\SubName##1{\def\nng@subname{##1}}% 予備の宛先
  \let \nng@zip \relax
  \let \nng@address \relax
  \let \nng@subaddress \relax
  \let \nng@name \relax
  \let \nng@subname \relax
}{%
  \def\@tempchar {-}%
  \let\nng@pri@zip\empty
  \let\nng@sec@zip\empty
  \@nng@tempswfalse
  \@tempcnta = \z@
  \expandafter\@tfor \expandafter\member 
     \expandafter:\expandafter=\nng@zip \do{%
     \advance \@tempcnta \@ne
     \ifnum \@tempcnta = 4
       \@nng@tempswtrue
     \fi
     \ifx \member \@tempchar
       \@nng@tempswtrue
       \let \member \empty
     \fi
     \if@nng@tempsw % 前半部分
       \edef\nng@sec@zip{\nng@sec@zip\member\space}%
     \else % 後半部分
       \edef\nng@pri@zip{\nng@pri@zip\member\space}%
     \fi
  }%

  \@tempcnta = \z@
  \expandafter\@tfor \expandafter\member 
     \expandafter:\expandafter=\nng@myoji \do{%
     \advance\@tempcnta \@ne
  }%
  \advance\@tempcnta \@ne
  \@tempcntb = -7
  \multiply \@tempcntb by \@tempcnta
  \advance \@tempcntb 110
  %
  \setlength\unitlength{1mm}%
  \begin{picture}(100,148)(0,0)%
   \put(44,128){\makebox(0,0)[bl]{\LARGE\nng@pri@zip}}%
   \put(66,128){\makebox(0,0)[bl]{\LARGE\nng@sec@zip}}%
   \put(80,120){\makebox(0,0)[tl]{\hbox{\tate\LARGE \nng@address}}}%
   \put(70,110){\makebox(0,0)[tl]{\hbox{\tate\LARGE \nng@subaddress}}}%
   \put(50,110){\makebox(0,0)[tl]{\hbox{\tate\huge \nng@myoji}}}%
   %((m * u) + 100mm)
   \put(50,\@tempcntb){\makebox(0,0)[tl]{\hbox{\tate\huge \nng@namae}}}%
   \put(40,\@tempcntb){\makebox(0,0)[tl]{\hbox{\tate\huge \nng@subname}}}%
  \end{picture}%
}
% 
\makeatother

% 設定
\Keisyo{様}
\lmargin{0mm}
\tmargin{0mm}
\begin{document}

\begin{atena}
\Zip{0410833}
\Address{函館市高森町86番地163}
\SubAddress{コーポタメクニ206号}
\Name{北海}{太郎}
\SubName{花子}
\end{atena}

\begin{atena}
\Zip{000-0033} 
\Address{東京都千葉市箱根8-3-1}
\SubAddress{ハイツマンション 205号}
\Name{佐々木}{小次郎}
\end{atena}
\end{document}