Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created January 1, 2024 00:07
Show Gist options
  • Save zr-tex8r/4acaf36613efcfa0e89d3ca737b15e37 to your computer and use it in GitHub Desktop.
Save zr-tex8r/4acaf36613efcfa0e89d3ca737b15e37 to your computer and use it in GitHub Desktop.
LaTeX: New year post card of the year 2024
%#!lualatex
\documentclass{article}
\usepackage[papersize={100mm,148mm},margin=0cm,
noheadfoot]{geometry}
\usepackage{luatexja-fontspec}
\usepackage{amsmath,tikz,graphicx,xcolor,xparse,pgfmath,ifthen}
\newboolean{soeikakupoptai}
%↓チュノムの漢字を出力するフォントの設定.
%trueの場合は"創英角ポップ体"が使われる.
%falseの場合は"花園明朝A/B"が使われる.
\setboolean{soeikakupoptai}{false}
\ltjsetparameter{jacharrange={-2}}
\usetikzlibrary{calc,positioning}
\colorlet{k}{black}
\newcommand{\cLet}{\pgfmathsetmacro}
\newlength{\lUnit}
\newfontface{\fLobs}{LobsterTwo Bold}
\newfontface{\fAudi}{Audiowide-Regular.ttf}
\newfontface{\fNishiki}{Nishiki-teki.ttf}
\newjfontface{\jNishiki}{Nishiki-teki.ttf}
\newfontface{\fYuji}{YujiSyuku-Regular.ttf}
\newjfontface{\jYuji}{YujiSyuku-Regular.ttf}
\newfontfamily{\fSHSans}{HaranoAjiGothic-Medium.otf}[
BoldFont=HaranoAjiGothic-Heavy.otf]
\newjfontfamily{\jSHSans}{HaranoAjiGothic-Medium.otf}[
BoldFont=HaranoAjiGothic-Bold.otf]
\definecolor{myred}{rgb}{1,0,0}
\definecolor{myblue}{rgb}{0,0.2,1}
\definecolor{mygreen}{rgb}{0,0.45,0.1}
\definecolor{mycyan}{rgb}{0,0.6,1}
\definecolor{myorange}{rgb}{1,0.5,0}
\NewDocumentCommand{\xZ}{}{\hspace*{0pt}}
\NewDocumentCommand{\xYS}{}{\hspace*{0.75em}}
\NewDocumentEnvironment{xPar}{}{%
\par}{\par}
\NewDocumentCommand\xSize{O{0}m}{%
\fontsize{#2}{#1}\selectfont}
\begin{document}
%=================================================
\ifthenelse{\boolean{soeikakupoptai}}{
\newcommand*{\cNPict}[1]{%
\begin{tikzpicture}[x=1\zw, y=1\zw, baseline=0pt,
every node/.style={anchor=base}]
\useasboundingbox (0,-.12) rectangle (1,.88); #1
\end{tikzpicture}}
\newcommand*{\cNScope}[3]{%
\begin{scope}[xshift=#1\zw, xscale=#2, transform shape] #3
\end{scope}}
\newcommand*{\cNChar}[1]{%
\node at (.50,0) {\symbol{#1}};}
\newjfontface{\jNomA}{HGSoeiKakupoptai}% 創英角ポップ体
\newcommand*{\xChuc}{\cNPict{\cNChar{"795D}}}%<祝>
\newcommand*{\xMung}{\cNPict{%
\cNScope{-.01}{.92}{%
\clip(0,.88)--(.4,.88)--(.4,.45)--(.408,.4)--(.4,.35)--(.3,.3)--%
(.3,.2)--(.285,.1)--(.285,0)--(.3,-.05)--(.3,-.12)--(0,-.12)--%
cycle;
\cNChar{"60E7}}%<惧>
\cNScope{.32}{.68}{\cNChar{"660E}}}}%<明>
\newcommand*{\xNam}{\cNPict{%
\cNScope{-.01}{1}{%
\clip(0,.88)--(.55,.88)--(.55,.65)--(.525,.6)--(.525,0)--%
(.52,-.12)--(0,-.12)--cycle;
\cNChar{"732E}}%<献>
\cNScope{.5}{.64}{%
\clip(0,.88)--(.671,.88)--(.671,-.12)--(0,-.12)--cycle;
\cNChar{"5E74}}%<年>
\cNScope{.7814}{.22}{%
\clip(1,.88)--(.67,.88)--(.67,-.12)--(1,-.12)--cycle;
\cNChar{"5E74}}}}%<年>
\newcommand*{\xMoi}{\cNPict{%
\cNScope{0}{1}{%
\clip(0,.88)--(.3,.88)--(.3,.65)--(.25,.6)--(.25,.3)--(.28,.25)--%
(.25,.15)--(.25,-.12)--(0,-.12)--cycle;
\cNChar{"7006}}%<瀆>
\cNScope{.265}{.75}{\cNChar{"8CB7}}}}%<買>
}{%else
\newjfontface{\jNomA}{HanaMinA}[FakeBold=4]% 花園明朝A
\newjfontface{\jNomB}{HanaMinB}[FakeBold=4]% 花園明朝B
\newcommand*{\xChuc}{\symbol{"795D}}%<祝>
\newcommand*{\xMung}{{\jNomB\symbol{"22720}}}%<𢜠>
\newcommand*{\xNam}{{\jNomB\symbol{"221A5}}}%<𢆥>
\newcommand*{\xMoi}{\symbol{"3D4B}}%<㵋>
}
\begin{xPar}\centering
\jNomA\xSize{38}\color{myred}
\raisebox{0pt}[18mm][0mm]{%
\xChuc\xYS\xMung\xYS\xNam\xYS\xMoi}
\end{xPar}
%=================================================
\vspace{6mm}
%=================================================
\begin{xPar}\centering
\setlength{\lUnit}{0.01cm}
\cLet{\vScale}{1.620375}
%
\definecolor{dblue} {rgb}{0.00, 0.00, 0.98}
\definecolor{dgreen} {rgb}{0.00, 0.50, 0.00}
\definecolor{yellow0}{rgb}{1.00, 1.00, 0.00}
\definecolor{yellow1}{rgb}{1.00, 1.00, 0.75}
\definecolor{cyan0} {rgb}{0.00, 0.80, 1.00}
\definecolor{cyan1} {rgb}{0.00, 1.00, 0.00}
\definecolor{red0} {rgb}{1.00, 0.10, 0.10}
\definecolor{red1} {rgb}{1.00, 0.40, 0.00}
%
\begin{tikzpicture}[x=\lUnit, y=\lUnit, scale=\vScale]
\fill[black, use as bounding box] (-16,-16) rectangle (416,416);
%\node[transform shape] at (368,-8)
% {\includegraphics[width=7.04mm]{yato.png}};
%
\clip (1,1) rectangle (399,399);
\shade[top color=yellow1, bottom color=yellow0]
(0,179) rectangle (400,301);
\shade[top color=red1, bottom color=red0]
(59,0)--(59,121)--(326,121)--(65,0)--cycle;
\shade[left color=cyan0, right color=cyan1]
(205,0)--(400,0)--(400,87)--cycle;
%
\begin{scope}
\clip (0,0)--(0,400)--(400,400)--
(400,300)--(100,300)--(100,180)--(400,180)--
(400,86)--(339,60)--(400,34)--
(400,0)--(322,0)--(264,27)--(206,0)--
cycle
(400,280)--(400,200)--(120,200)--(120,280)--
cycle
(60,0)--(100,20)--(100,120)--(60,120)--
cycle
(160,47)--(190,60)--(160,73)--
cycle
(205,120)--(265,94)--(325,120)--
cycle
;
\shade[top color=dblue, bottom color=dgreen, shading angle=-45]
(0,0) rectangle (400,400);
\end{scope}
\node[above left=0pt, font={\fAudi\xSize{28}}, text=white]
at (396,300) {2\,O\,2\,4};
\end{tikzpicture}
\end{xPar}
%=================================================
\vspace{1mm}
\begin{xPar}\centering
\fYuji\jYuji\xSize[13]{12}%
\ltjsetparameter{kanjiskip=-.07\zw,xkanjiskip=-.04\zw}
皆様のご健康とご多幸を\\
お祈り申し上げます
\end{xPar}
\vspace{3mm}
\begin{xPar}\centering\begin{minipage}{90mm}
\begin{xPar}
\fNishiki\jNishiki\xSize{16}\color{myred}
New Year Puzzle%
\hfill
{\xSize{14}\color{myred}%
2024}%
{\xSize{9}\color{mygreen!75!black}%
\,年(令和\,}%
{\xSize{14}\color{myred}%
6}%
{\xSize{9}\color{mygreen!75!black}%
\,年)}%
\end{xPar}
\begin{xPar}
\fNishiki\jNishiki\xSize{12}\color{myblue!75!black}%
~年賀パズル~
\end{xPar}
\par\vspace{-4mm}
\hspace*{1mm}%
{\fSHSans\jSHSans\xSize{7}
\newcommand*{\xBox}[1]{%
\tikz[baseline=0.12\zw]{%
\path[thick, draw=mygreen, fill=#1]
(0,0) rectangle (1\zw,1\zw)}}
\newcommand*{\xEm}[1]{\textcolor{myred}{\bfseries#1}}
\newcommand*{\xBr}{\linebreak[4]}
\begin{minipage}[b]{13\zw}
\setlength\leftmargini{2.2\zw}
\setlength\leftmargin{2.2\zw}
以下の条件に従って掛け算の虫食い算を解きなさい。
\par\vspace{-2mm}
\begin{itemize}
\setlength{\itemsep}{-3pt}
\item \xBox{myorange!40}\,の\xEm{6}マスおよび\,
\xBox{mycyan!40}\,の\xEm{6}マスはそれぞれ
\xEm{6}面\xBr ダイス\,\scalebox{0.7}{(立方体のサイコロ)}\,の\xBr
\textcolor{mygreen}{展開図}になっている。
\end{itemize}
\par\vspace{-2mm}
\xSize{5}
※6面ダイスの向かい合う面に書かれた数の和は7でなければならない。
\par\vspace*{1mm}
\end{minipage}}%
\begin{minipage}[b]{59mm}\raggedleft
\DeclareDocumentCommand{\crB}{r()}{%
\node[crbox] at (#1) {};
}
\DeclareDocumentCommand{\crD}{r()}{%
\node[crbox1] at (#1) {};
}
\DeclareDocumentCommand{\crE}{r()}{%
\node[crbox2] at (#1) {};
}
\DeclareDocumentCommand{\crX}{r()}{%
\node[crboxX] at (#1) {};
}
%
\scalebox{0.40}{\begin{tikzpicture}[x=1mm,y=1mm,
crline/.style={draw=myblue, line width=1.8pt},
crbox/.style={draw=mygreen},
crbox1/.style={draw=mygreen, fill=myorange!40},
crbox2/.style={draw=mygreen, fill=mycyan!40},
crboxX/.style={draw=myred},
every node/.style={rectangle, line width=0.8mm,
minimum width=10mm, minimum height=10mm}]
%\fill[myred!20] (95,-5) rectangle (135,5);
\crB(60,70)\crB(70,70)\crB(80,70)\crB(90,70)\crB(100,70)\crB(110,70)
\crB(70,60)\crD(80,60)\crB(90,60)\crB(100,60)\crB(110,60)
\crD(50,50)\crD(60,50)\crD(70,50)\crD(80,50)\crB(90,50)\crB(100,50)\crB(110,50)
\crB(40,40)\crB(50,40)\crB(60,40)\crB(70,40)\crD(80,40)\crE(90,40)\crE(100,40)
\crB(30,30)\crB(40,30)\crB(50,30)\crB(60,30)\crB(70,30)\crE(80,30)\crE(90,30)
\crB(30,20)\crB(40,20)\crB(50,20)\crB(60,20)\crE(70,20)\crE(80,20)
\crB(20,10)\crB(30,10)\crB(40,10)\crB(50,10)\crB(60,10)\crB(70,10)
\crB(10,00)\crB(20,00)\crB(70,00)\crB(80,00)\crB(90,00)\crB(100,00)\crB(110,00)
\draw[crline] (-7,55)--(120,55);
\draw[crline] (-7,5)--(120,5);
\draw[crline] (-2,63)--(2,59) (-2,59)--(2,63);
\crX(30,00)\crX(40,00)\crX(50,00)\crX(60,00)
\end{tikzpicture}}%
\end{minipage}%
\par\vspace{-1mm}
\end{minipage}\end{xPar}
\end{document}
@zr-tex8r
Copy link
Author

zr-tex8r commented Jan 1, 2024

11行目の\setbooleanの値により「チュノムの漢字を出力するフォント」の設定を選択する。

  • trueの場合は「創英角ポップ体」が使われる。
  • falseの場合は「花園明朝A」「花園明朝B」が使われる。
    • 78~79行目を書き換えると他のフォントも選択できる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment