| 1 |
\documentclass[luatex,fontsize=8pt,paper=b5,twoside]{jlreq}% |
| 2 |
\usepackage{amsmath,amssymb} |
| 3 |
\usepackage{booktabs,caption} |
| 4 |
\usepackage{luwa-ul} |
| 5 |
\usepackage[most]{tcolorbox} |
| 6 |
\usepackage{luatexja-ruby} |
| 7 |
\usepackage{keisennote} |
| 8 |
|
| 9 |
\usepackage{listings} |
| 10 |
\lstset{ |
| 11 |
basicstyle=\ttfamily\small, |
| 12 |
keywordstyle=\color{blue}, |
| 13 |
commentstyle=\color{gray}, |
| 14 |
stringstyle=\color{red}, |
| 15 |
breaklines=true, |
| 16 |
breakatwhitespace=false, |
| 17 |
columns=flexible |
| 18 |
} |
| 19 |
|
| 20 |
% You can omit these font settings. |
| 21 |
\makeatletter |
| 22 |
\RequirePackage[no-math]{fontspec} |
| 23 |
\RequirePackage[no-math,match,scale=1]{luatexja-fontspec} |
| 24 |
\RequirePackage[hiragino-pro,deluxe,expert]{luatexja-preset} |
| 25 |
\setmainfont{HiraMinPro-W3}[BoldFont=HiraMinPro-W6] |
| 26 |
\setmainjfont{HiraMinPro-W3}[BoldFont=HiraMinPro-W6] |
| 27 |
\newfontfamily{\sfhira@pre}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6] |
| 28 |
\newjfontfamily{\sfhiraj@pre}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6] |
| 29 |
\newfontfamily{\mchira@pre}{HiraMinPro-W3}[BoldFont=HiraMinPro-W6] |
| 30 |
\newjfontfamily{\mchiraj@pre}{HiraMinPro-W3}[BoldFont=HiraMinPro-W6] |
| 31 |
\newfontfamily{\gthira@pre}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6,FontFace={eb}{\shapedefault}{HiraKakuStd-W8}] |
| 32 |
\newjfontfamily{\gthiraj@pre}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6,FontFace={eb}{\shapedefault}{HiraKakuStd-W8}] |
| 33 |
\newfontfamily{\mghira@pre}{HiraMaruPro-W4} |
| 34 |
\newjfontfamily{\mghiraj@pre}{HiraMaruPro-W4} |
| 35 |
\renewcommand{\sffamily}{\sfhira@pre\sfhiraj@pre} |
| 36 |
\renewcommand{\mcfamily}{\mchira@pre\mchiraj@pre} |
| 37 |
\renewcommand{\gtfamily}{\gthira@pre\gthiraj@pre} |
| 38 |
\renewcommand{\mgfamily}{\mghira@pre\mghiraj@pre} |
| 39 |
\makeatother |
| 40 |
%%% |
| 41 |
|
| 42 |
|
| 43 |
\usepackage{hyperref} |
| 44 |
\hypersetup{ |
| 45 |
luatex, pdfencoding=auto, |
| 46 |
colorlinks=true, |
| 47 |
linkcolor=black, |
| 48 |
citecolor=black, |
| 49 |
urlcolor=DeepSkyBlue3, |
| 50 |
pdfborder={0 0 0}, |
| 51 |
} |
| 52 |
|
| 53 |
\colorlet{grayLight}{white!80!black} |
| 54 |
|
| 55 |
\NewTCBListing{SourceCode}{ m m !o !O{DeepSkyBlue3} }{% |
| 56 |
enhanced, colback=black!70, colframe=Snow4, |
| 57 |
toptitle=-1mm, bottomtitle=-1mm, |
| 58 |
righttitle=-1mm, lefttitle=-1mm, |
| 59 |
arc=.5mm, |
| 60 |
title={\tcbox[on line, arc=.5mm, boxsep=0pt, boxrule=0pt, top=1mm, bottom=0.8mm, left=2mm, right=2.2mm, colback=gray!80, coltext=white]{\raisebox{-0.1ex}{\vphantom{羅}\vphantom{j}#1}}},fonttitle=\gtfamily\footnotesize,boxrule=0.8pt, |
| 61 |
breakable,before upper={\color{white}},top=-0.5mm,bottom=-0.5mm, |
| 62 |
after title=\IfNoValueTF{#3}{}{{\hfill\tcbox[on line, arc=.5mm, boxsep=0pt, boxrule=0pt, top=1mm, bottom=0.8mm, left=2mm, right=2.2mm, colback=white!80!black, coltext=#4]{\raisebox{-0.1ex}{\vphantom{羅}\vphantom{j}#3}}}}, |
| 63 |
listing only, |
| 64 |
listing options={ |
| 65 |
language={#2}, |
| 66 |
basicstyle=\ttfamily, |
| 67 |
keywordstyle=\ttfamily\color{white}, |
| 68 |
stringstyle=\itshape\color{white}, |
| 69 |
commentstyle=\small\gtfamily\color{DeepSkyBlue2}, |
| 70 |
showspaces=false,showtabs=false, |
| 71 |
breaklines=true,breakindent=0pt, |
| 72 |
showstringspaces=false, |
| 73 |
columns=fullflexible, |
| 74 |
tabsize=2, |
| 75 |
numbers=left,numbersep=1.5pt, |
| 76 |
numberstyle=\scriptsize\gtfamily\color{gray}, |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
\NewTColorBox{OutPut}{ m !o !O{DeepSkyBlue3} }{% |
| 81 |
enhanced, colframe=Snow4, |
| 82 |
toptitle=-1mm, bottomtitle=-1mm, |
| 83 |
righttitle=-1mm, lefttitle=-1mm, |
| 84 |
arc=.5mm, colback=white, |
| 85 |
title={\tcbox[on line, arc=.5mm, boxsep=0pt, boxrule=0pt, top=1mm, bottom=0.8mm, left=2mm, right=2.2mm, colback=gray!40, coltext=DeepSkyBlue3]{\raisebox{-0.1ex}{\vphantom{羅}\vphantom{j}#1}}},fonttitle=\gtfamily\footnotesize,boxrule=0.8pt, |
| 86 |
breakable,top=-0.5mm,bottom=-0.5mm, |
| 87 |
after title=\IfNoValueTF{#2}{}{{\hfill\tcbox[on line, arc=.5mm, boxsep=0pt, boxrule=0pt, top=1mm, bottom=0.8mm, left=2mm, right=2.2mm, colback=white!80!black, coltext=#3]{\raisebox{-0.1ex}{\vphantom{羅}\vphantom{j}#2}}}}, bottom=2mm, top=2mm, |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
\title{\texttt{keisennote} Package Documentation} |
| 92 |
\author{Kosei Kawaguchi a.k.a. KKTeX} |
| 93 |
\date{Version 1.2.0 (2025/12/30)} |
| 94 |
|
| 95 |
\begin{document} |
| 96 |
\begin{titlepage} |
| 97 |
\maketitle |
| 98 |
\end{titlepage} |
| 99 |
\newpage |
| 100 |
\tableofcontents |
| 101 |
\newpage |
| 102 |
|
| 103 |
\section{Acknowledgements / Credit} |
| 104 |
This package is based on the code from \href{https://qiita.com/VoD/items/6849e63b978050218d2f}{VoD's Qiita article}, |
| 105 |
with some improvements. The original author has kindly granted permission |
| 106 |
to release this as a LaTeX package. Special thanks to VoD for their contribution to the TeX community. |
| 107 |
|
| 108 |
\section{Installation} |
| 109 |
Place \texttt{keisennote.sty} in a directory where LaTeX can find it. |
| 110 |
Dependencies: \texttt{xcolor}, \texttt{tikz}, \texttt{zref}, \texttt{zref-savepos}, \texttt{fp}, \texttt{kvoptions}. |
| 111 |
|
| 112 |
\section{Package options} |
| 113 |
Set global defaults at load time using key-value style. |
| 114 |
|
| 115 |
\bigskip |
| 116 |
\begin{center} |
| 117 |
\begin{tabular}{l l p{.5\linewidth}} |
| 118 |
\toprule |
| 119 |
Option name & Default value & Description \\ |
| 120 |
\midrule |
| 121 |
\texttt{linewidth} & \texttt{.5truept} & Width of the ruled lines. \\ |
| 122 |
\texttt{radius} & \texttt{.7truept} & Radius of dots on the lines. \\ |
| 123 |
\texttt{distance} & \texttt{6truemm} & Distance between lines (and dots). \\ |
| 124 |
\texttt{triangle} & \texttt{.7truept} & Scale of the center triangular markers. \\ |
| 125 |
\bottomrule |
| 126 |
\end{tabular} |
| 127 |
\end{center} |
| 128 |
\bigskip |
| 129 |
|
| 130 |
\section{Commands} |
| 131 |
All commands below accept an optional argument in \texttt{pgfkeys} format: |
| 132 |
\texttt{[color=..., show number=..., step=...]}. |
| 133 |
|
| 134 |
\subsection{Notebook Style (\texttt{\textbackslash notefill}, \texttt{\textbackslash note})} |
| 135 |
\begin{SourceCode}{Input}{TeX} |
| 136 |
\notefill[options] |
| 137 |
\note{<lines>}[options] |
| 138 |
\end{SourceCode} |
| 139 |
|
| 140 |
\texttt{\textbackslash notefill} automatically fills the remaining vertical space. \texttt{\textbackslash note} draws a block with the specified number of lines. |
| 141 |
|
| 142 |
\bigskip |
| 143 |
\textbf{Example with Line Numbers:} |
| 144 |
\begin{SourceCode}{Input}{TeX} |
| 145 |
\note{5}[color=RoyalBlue, show number=true, step=1] |
| 146 |
\end{SourceCode} |
| 147 |
\note{5}[color=RoyalBlue, show number=true, step=1] |
| 148 |
|
| 149 |
\subsection{Grid Style (\texttt{\textbackslash masumefill}, \texttt{\textbackslash masume})} |
| 150 |
\begin{SourceCode}{Input}{TeX} |
| 151 |
\masumefill*[options] |
| 152 |
\masume*{<lines>}[options] |
| 153 |
\end{SourceCode} |
| 154 |
|
| 155 |
The starred version (\texttt{*}) draws a thick outer frame around the grid. |
| 156 |
|
| 157 |
\bigskip |
| 158 |
\textbf{Example with Frame:} |
| 159 |
\begin{SourceCode}{Input}{TeX} |
| 160 |
\masume*{3}[color=Gray] |
| 161 |
\end{SourceCode} |
| 162 |
\masume*{3}[color=Gray] |
| 163 |
|
| 164 |
\section{Dynamic Parameter Adjustment} |
| 165 |
You can change the parameters in the middle of the document. |
| 166 |
|
| 167 |
\begin{description} |
| 168 |
\item[\texttt{\textbackslash SetNoteLineWidth[dim]}] Sets the line width. |
| 169 |
\item[\texttt{\textbackslash SetNoteDotRadius[dim]}] Sets the dot radius. |
| 170 |
\item[\texttt{\textbackslash SetNoteLineDistance[dim]}] Sets the line spacing. |
| 171 |
\item[\texttt{\textbackslash SetNoteTriangleSize[dim]}] Sets the marker size. |
| 172 |
\end{description} |
| 173 |
If the optional argument is omitted, the parameter is reset to its package default. |
| 174 |
|
| 175 |
\section{Technical Notes} |
| 176 |
\begin{itemize} |
| 177 |
\item \textbf{Multiple Compilations:} Commands like \texttt{\textbackslash notefill} use \texttt{zref-savepos} to determine the available space. You must compile the document \textbf{at least twice} to ensure the lines are drawn correctly. |
| 178 |
\item \textbf{Line Numbers:} The \texttt{show number} option displays the line count. For \texttt{\textbackslash note}, it counts down to 1. For \texttt{\textbackslash notefill}, it calculates the total capacity of the space. |
| 179 |
\end{itemize} |
| 180 |
|
| 181 |
\section{Examples} |
| 182 |
|
| 183 |
\subsection{Full Page Notebook Fill} |
| 184 |
\begin{SourceCode}{Input}{TeX} |
| 185 |
\notefill[color=lightgray, show number=true] |
| 186 |
\end{SourceCode} |
| 187 |
(See the next page for the result.) |
| 188 |
\newpage |
| 189 |
\notefill[color=lightgray, show number=true] |
| 190 |
|
| 191 |
\newpage |
| 192 |
|
| 193 |
\section{License} |
| 194 |
Released under the MIT License. |
| 195 |
|
| 196 |
\section{Version History} |
| 197 |
\begin{itemize} |
| 198 |
\item \textbf{v1.0.0 -- v1.0.4a} --- Initial versions, added grid commands and package options. |
| 199 |
\item \textbf{v1.2.0 (2025/12/30)} --- Added \texttt{pgfkeys} support for command options, improved \texttt{\textbackslash masume*} border logic, and changed license. |
| 200 |
\end{itemize} |
| 201 |
|
| 202 |
\section{Source Code} |
| 203 |
\begin{lstlisting} |
| 204 |
\ProvidesPackage{keisennote}[2025/12/30, v1.2.0] |
| 205 |
|
| 206 |
\RequirePackage[dvipsnames, svgnames, x11names]{xcolor} |
| 207 |
\RequirePackage{zref, zref-savepos, fp} |
| 208 |
\RequirePackage{tikz} |
| 209 |
|
| 210 |
\RequirePackage{kvoptions} |
| 211 |
|
| 212 |
\SetupKeyvalOptions{ |
| 213 |
family=kn, |
| 214 |
prefix=kn@ |
| 215 |
} |
| 216 |
|
| 217 |
\newdimen\noteLineWidth@kn |
| 218 |
\newdimen\noteDotsRadius@kn |
| 219 |
\newdimen\noteLineDistance@kn |
| 220 |
\newdimen\noteTriangle@mag@kn |
| 221 |
|
| 222 |
% パッケージオプションの宣言 |
| 223 |
\DeclareStringOption[.5truept]{linewidth}% 線の太さ |
| 224 |
\DeclareStringOption[.7truept]{radius}% ドットの大きさ |
| 225 |
\DeclareStringOption[6truemm]{distance}% ドットの間隔 |
| 226 |
\DeclareStringOption[.7truept]{triangle}% 三角形の大きさ |
| 227 |
\ProcessKeyvalOptions* |
| 228 |
|
| 229 |
|
| 230 |
% オプションの反映 |
| 231 |
\setlength{\noteLineWidth@kn}{\kn@linewidth} |
| 232 |
\setlength{\noteDotsRadius@kn}{\kn@radius} |
| 233 |
\setlength{\noteLineDistance@kn}{\kn@distance} |
| 234 |
\setlength{\noteTriangle@mag@kn}{\kn@triangle} |
| 235 |
|
| 236 |
|
| 237 |
% 途中でパラメータ変更ができるように |
| 238 |
\NewDocumentCommand{\SetNoteLineWidth}{O{.5truept}}{% |
| 239 |
\setlength{\noteLineWidth@kn}{#1} |
| 240 |
} |
| 241 |
\NewDocumentCommand{\SetNoteDotRadius}{O{.8truept}}{% |
| 242 |
\setlength{\noteDotsRadius@kn}{#1} |
| 243 |
} |
| 244 |
\NewDocumentCommand{\SetNoteLineDistance}{O{6truemm}}{% |
| 245 |
\setlength{\noteLineDistance@kn}{#1} |
| 246 |
} |
| 247 |
\NewDocumentCommand{\SetNoteTriangleSize}{O{.5pt}}{% |
| 248 |
\setlength{\noteTriangle@mag@kn}{#1} |
| 249 |
} |
| 250 |
|
| 251 |
% 内部レジスタ |
| 252 |
\newdimen\VDNT@currentXPos |
| 253 |
\newdimen\VDNT@currentYPos |
| 254 |
\newdimen\VDNT@Xinterval |
| 255 |
\newdimen\VDNT@Yinterval |
| 256 |
\newdimen\VDNT@notegoal |
| 257 |
\def\VDNT@xscaler{.996} |
| 258 |
|
| 259 |
% \notefillで用いる座標管理用カウンタの準備 |
| 260 |
\def\VDNT@pkgname{vodnote} |
| 261 |
\global\newcount\VDNT@uniqe |
| 262 |
|
| 263 |
|
| 264 |
% 行間算出 |
| 265 |
\newcount\kn@linecount@internal |
| 266 |
\newcommand{\cal@kn@internal}{% |
| 267 |
\FPeval\VDNT@dotsNum{round(round(((\the)\@tempcnta/(\the)\@tempcntb)/2:0)*2:0)}% |
| 268 |
\VDNT@Xinterval\dimexpr(\linewidth)/\VDNT@dotsNum\relax% |
| 269 |
\VDNT@Yinterval\VDNT@Xinterval% |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
% \notefill の定義 |
| 274 |
% \notefill用内部マクロ |
| 275 |
\newcommand{\savepos@kn@internal@notefill}{% |
| 276 |
\zsaveposy{\VDNT@pkgname.\the\[email protected]}% 上端の座標取得 |
| 277 |
\leavevmode\vfill\leavevmode% 下まで移動→座標記憶 |
| 278 |
\zsaveposy{\VDNT@pkgname.\the\[email protected]}% 下端の座標取得 |
| 279 |
} |
| 280 |
\newcommand{\cal@kn@internal@notefill}{% |
| 281 |
\VDNT@notegoal=\dimexpr |
| 282 |
\zposy{\VDNT@pkgname.\the\[email protected]}sp |
| 283 |
-\zposy{\VDNT@pkgname.\the\[email protected]}sp |
| 284 |
\relax% |
| 285 |
} |
| 286 |
\newif\ifVDNT@shownumber |
| 287 |
\pgfkeys{ |
| 288 |
/VDNT/.is family, /VDNT, |
| 289 |
color/.estore in = \VDNT@color, |
| 290 |
step/.estore in = \VDNT@step, |
| 291 |
show number/.is if = VDNT@shownumber, |
| 292 |
default/.style = {color=white!70!black, step=5} |
| 293 |
} |
| 294 |
|
| 295 |
\NewDocumentCommand{\notefill}{ O{} }{% |
| 296 |
\par\bgroup% |
| 297 |
\pgfkeys{/VDNT, default, #1}% |
| 298 |
\parindent\z@% |
| 299 |
\@tempcnta\linewidth% 総横幅 |
| 300 |
\@tempcntb\noteLineDistance@kn% 単位横幅 |
| 301 |
\cal@kn@internal% |
| 302 |
\savepos@kn@internal@notefill% |
| 303 |
\cal@kn@internal@notefill% |
| 304 |
%%%行数算出 |
| 305 |
\pgfmathtruncatemacro{\VDNT@totalLines}{floor(\VDNT@notegoal / \VDNT@Yinterval)}% |
| 306 |
%%% |
| 307 |
% ノート罫線描画本体 |
| 308 |
\noindent\smash{% |
| 309 |
\begin{tikzpicture}[xscale=\VDNT@xscaler] |
| 310 |
\VDNT@currentYPos\z@ |
| 311 |
%%% |
| 312 |
\kn@linecount@internal=\VDNT@totalLines\relax % 初期値を総行数に設定 |
| 313 |
\advance\kn@linecount@internal by \@ne\relax % |
| 314 |
%%% |
| 315 |
% 上端の三角 |
| 316 |
\coordinate (TopMarkerTip) at (\VDNT@Xinterval*\VDNT@dotsNum/2, \VDNT@currentYPos+\noteTriangle@mag@kn*4pt); |
| 317 |
\fill[\VDNT@color] (TopMarkerTip) -- ++(\noteTriangle@mag@kn*3pt,-\noteTriangle@mag@kn*4pt) -- ++(-\noteTriangle@mag@kn*6pt,0) -- cycle; |
| 318 |
% 罫線とドットのループ描画 |
| 319 |
\@whiledim\VDNT@currentYPos<\VDNT@notegoal\do{% |
| 320 |
% 横線の左端(L)と右端(R) |
| 321 |
\coordinate (L) at (0, \VDNT@currentYPos); |
| 322 |
\coordinate (R) at (\linewidth, \VDNT@currentYPos); |
| 323 |
% --- 行番号の描画 --- |
| 324 |
\ifVDNT@shownumber |
| 325 |
\pgfmathtruncatemacro{\rem@notefill}{mod(\kn@linecount@internal,\VDNT@step)} |
| 326 |
\ifnum\rem@notefill=0 |
| 327 |
\node[anchor=east, font=\scriptsize, text=\VDNT@color, overlay] at ([xshift=-\f@size/2pt]L) {\the\kn@linecount@internal}; |
| 328 |
\fi |
| 329 |
\fi |
| 330 |
% -------------------- |
| 331 |
% 罫線を引く |
| 332 |
\draw[\VDNT@color, line width=\noteLineWidth@kn] (L) -- (R); |
| 333 |
% ループ内のドット描画部分 |
| 334 |
\foreach \k in{0,1,...,\VDNT@dotsNum}{% |
| 335 |
\pgfmathtruncatemacro{\VDNT@halfNum}{\VDNT@dotsNum/2}% |
| 336 |
\def\do@draw@dot{1}% 描画フラグを立てる |
| 337 |
% 「現在の行が最初」かつ「kが真ん中」ならフラグを折る |
| 338 |
\ifdim\VDNT@currentYPos=0pt\relax |
| 339 |
\ifnum\k=\VDNT@halfNum \def\do@draw@dot{0}\fi |
| 340 |
\fi |
| 341 |
% 「現在の行が最後(次がない)」かつ「kが真ん中」ならフラグを折る |
| 342 |
% \VDNT@notegoal との比較で行う |
| 343 |
\VDNT@currentXPos=\dimexpr\VDNT@currentYPos+\VDNT@Yinterval\relax |
| 344 |
\ifdim\VDNT@currentXPos<\VDNT@notegoal\else |
| 345 |
\ifnum\k=\VDNT@halfNum \def\do@draw@dot{0}\fi |
| 346 |
\fi |
| 347 |
\ifnum\do@draw@dot=1\relax |
| 348 |
\coordinate (Dot) at (\the\dimexpr\VDNT@Xinterval*\k\relax, \VDNT@currentYPos); |
| 349 |
\fill[\VDNT@color] (Dot) circle [radius=\noteDotsRadius@kn]; |
| 350 |
\fi |
| 351 |
} |
| 352 |
% 次の行へ移動 |
| 353 |
\advance\VDNT@currentYPos\VDNT@Yinterval\relax |
| 354 |
%%%カウントダウン |
| 355 |
\advance\kn@linecount@internal by -\@ne\relax |
| 356 |
%%% |
| 357 |
} |
| 358 |
% 下端の三角 |
| 359 |
% 座標を定義:(中心X, 最後の行Y - 4pt) |
| 360 |
\coordinate (BottomMarkerTip) at (\VDNT@Xinterval*\VDNT@dotsNum/2, \VDNT@currentYPos-\VDNT@Yinterval-\noteTriangle@mag@kn*4pt); |
| 361 |
\fill[\VDNT@color] (BottomMarkerTip) -- ++(\noteTriangle@mag@kn*3pt,\noteTriangle@mag@kn*4pt) -- ++(-\noteTriangle@mag@kn*6pt,0) -- cycle; |
| 362 |
\end{tikzpicture}% |
| 363 |
}% |
| 364 |
\egroup% |
| 365 |
\global\advance\VDNT@uniqe\@ne% 描画番号を進める |
| 366 |
\par% |
| 367 |
} |
| 368 |
|
| 369 |
\NewDocumentCommand{\masumefill}{ s O{} }{% |
| 370 |
\par\bgroup% |
| 371 |
\pgfkeys{/VDNT, default, #2}% |
| 372 |
\parindent\z@% |
| 373 |
\@tempcnta\linewidth% 総横幅 |
| 374 |
\@tempcntb\noteLineDistance@kn% 単位横幅 |
| 375 |
\cal@kn@internal% |
| 376 |
\savepos@kn@internal@notefill% |
| 377 |
\cal@kn@internal@notefill% |
| 378 |
%%%行数算出 |
| 379 |
\pgfmathtruncatemacro{\VDNT@totalLines}{floor(\VDNT@notegoal / \VDNT@Yinterval)}% |
| 380 |
%%% |
| 381 |
% ノート罫線描画本体 |
| 382 |
\noindent\smash{% |
| 383 |
\begin{tikzpicture}[xscale=\VDNT@xscaler] |
| 384 |
\VDNT@currentYPos\z@ |
| 385 |
%%% |
| 386 |
\kn@linecount@internal=\VDNT@totalLines\relax % 初期値を総行数に設定 |
| 387 |
\advance\kn@linecount@internal by \@ne\relax % |
| 388 |
%%% |
| 389 |
% 上端の三角 |
| 390 |
\coordinate (TopMarkerTip) at (\VDNT@Xinterval*\VDNT@dotsNum/2, \VDNT@currentYPos+\noteTriangle@mag@kn*4pt); |
| 391 |
\fill[\VDNT@color] (TopMarkerTip) -- ++(\noteTriangle@mag@kn*3pt,-\noteTriangle@mag@kn*4pt) -- ++(-\noteTriangle@mag@kn*6pt,0) -- cycle; |
| 392 |
% 罫線とドットのループ描画 |
| 393 |
\@whiledim\VDNT@currentYPos<\VDNT@notegoal\do{% |
| 394 |
% 横線の左端(L)と右端(R) |
| 395 |
\coordinate (L) at (0, \VDNT@currentYPos); |
| 396 |
\coordinate (R) at (\linewidth, \VDNT@currentYPos); |
| 397 |
% --- 行番号の描画 --- |
| 398 |
\ifVDNT@shownumber |
| 399 |
\pgfmathtruncatemacro{\rem@notefill}{mod(\kn@linecount@internal,\VDNT@step)} |
| 400 |
\ifnum\rem@notefill=0 |
| 401 |
\node[anchor=east, font=\scriptsize, text=\VDNT@color, overlay] at ([xshift=-\f@size/2pt]L) {\the\kn@linecount@internal}; |
| 402 |
\fi |
| 403 |
\fi |
| 404 |
% -------------------- |
| 405 |
% 罫線を引く |
| 406 |
\draw[\VDNT@color, line width=\noteLineWidth@kn] (L) -- (R); |
| 407 |
% ループ内のドット描画部分 |
| 408 |
\foreach \k in{0,1,...,\VDNT@dotsNum}{% |
| 409 |
\pgfmathtruncatemacro{\VDNT@halfNum}{\VDNT@dotsNum/2}% |
| 410 |
\def\do@draw@dot{1}% 描画フラグを立てる |
| 411 |
% 「現在の行が最初」かつ「kが真ん中」ならフラグを折る |
| 412 |
\ifdim\VDNT@currentYPos=0pt\relax |
| 413 |
\ifnum\k=\VDNT@halfNum \def\do@draw@dot{0}\fi |
| 414 |
\fi |
| 415 |
% 「現在の行が最後(次がない)」かつ「kが真ん中」ならフラグを折る |
| 416 |
% \VDNT@notegoal との比較で行う |
| 417 |
\VDNT@currentXPos=\dimexpr\VDNT@currentYPos+\VDNT@Yinterval\relax |
| 418 |
\ifdim\VDNT@currentXPos<\VDNT@notegoal\else |
| 419 |
\ifnum\k=\VDNT@halfNum \def\do@draw@dot{0}\fi |
| 420 |
\fi |
| 421 |
% ------------------ |
| 422 |
\coordinate (VBottom) at (\the\dimexpr\VDNT@Xinterval*\k\relax, \VDNT@currentYPos); |
| 423 |
\VDNT@currentXPos=\dimexpr\VDNT@currentYPos+\VDNT@Yinterval\relax |
| 424 |
\ifdim\VDNT@currentXPos<\VDNT@notegoal\relax |
| 425 |
\draw[\VDNT@color, line width=\noteLineWidth@kn] (VBottom) -- ++(0, \VDNT@Yinterval); |
| 426 |
\fi |
| 427 |
% ------------------ |
| 428 |
\ifnum\do@draw@dot=1\relax |
| 429 |
\coordinate (Dot) at (\the\dimexpr\VDNT@Xinterval*\k\relax, \VDNT@currentYPos); |
| 430 |
\fill[\VDNT@color] (Dot) circle [radius=\noteDotsRadius@kn]; |
| 431 |
\fi |
| 432 |
} |
| 433 |
% 次の行へ移動 |
| 434 |
\advance\VDNT@currentYPos\VDNT@Yinterval\relax |
| 435 |
%%%カウントダウン |
| 436 |
\advance\kn@linecount@internal by -\@ne\relax |
| 437 |
%%% |
| 438 |
} |
| 439 |
% 外枠描画 |
| 440 |
\IfBooleanT{#1}{% |
| 441 |
\draw[\VDNT@color, line width=\noteLineWidth@kn*2.5] (0,0) rectangle (\linewidth, \the\dimexpr\VDNT@currentYPos-\VDNT@Yinterval\relax); |
| 442 |
}% |
| 443 |
% 下端の三角 |
| 444 |
% 座標を定義:(中心X, 最後の行Y - 4pt) |
| 445 |
\coordinate (BottomMarkerTip) at (\VDNT@Xinterval*\VDNT@dotsNum/2, \VDNT@currentYPos-\VDNT@Yinterval-\noteTriangle@mag@kn*4pt); |
| 446 |
\fill[\VDNT@color] (BottomMarkerTip) -- ++(\noteTriangle@mag@kn*3pt,\noteTriangle@mag@kn*4pt) -- ++(-\noteTriangle@mag@kn*6pt,0) -- cycle; |
| 447 |
\end{tikzpicture}% |
| 448 |
}% |
| 449 |
\egroup% |
| 450 |
\global\advance\VDNT@uniqe\@ne% 描画番号を進める |
| 451 |
\par% |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
% \note の定義(2以上の整数を引数に) |
| 456 |
\NewDocumentCommand{\note}{ m O{} }{% |
| 457 |
\par\bgroup% |
| 458 |
\pgfkeys{/VDNT, default, #2}% |
| 459 |
\@tempcnta\linewidth% |
| 460 |
\@tempcntb\noteLineDistance@kn% |
| 461 |
\cal@kn@internal% |
| 462 |
\noindent% |
| 463 |
\begin{tikzpicture}[xscale=\VDNT@xscaler] |
| 464 |
\VDNT@currentYPos\z@ |
| 465 |
%%% |
| 466 |
\kn@linecount@internal=#1\relax |
| 467 |
%%% |
| 468 |
\coordinate (TopMarker) at (\VDNT@Xinterval*\VDNT@dotsNum/2, \VDNT@Yinterval+\noteTriangle@mag@kn*4pt); |
| 469 |
\fill[\VDNT@color] (TopMarker) -- ++(\noteTriangle@mag@kn*3pt, -\noteTriangle@mag@kn*4pt) -- ++(-\noteTriangle@mag@kn*6pt, 0) -- cycle; |
| 470 |
\foreach \i in {1, 2, ..., #1} {% |
| 471 |
\xdef\tempY{\the\dimexpr\VDNT@Yinterval*\i\relax} |
| 472 |
\coordinate (LineL) at (0, \tempY); |
| 473 |
\coordinate (LineR) at (\linewidth, \tempY); |
| 474 |
% --- 行番号の描画 --- |
| 475 |
\ifVDNT@shownumber |
| 476 |
\pgfmathtruncatemacro{\VDNT@currentnum}{#1 - \i + 1 } |
| 477 |
\pgfmathtruncatemacro{\rem@notefill}{mod(\VDNT@currentnum,\VDNT@step)} |
| 478 |
\ifnum\rem@notefill=0 |
| 479 |
\node[anchor=east, font=\scriptsize, text=\VDNT@color, overlay] at ([xshift=-\f@size/2pt]LineL) {\VDNT@currentnum}; |
| 480 |
\fi |
| 481 |
\fi |
| 482 |
% -------------------- |
| 483 |
\draw[\VDNT@color, line width=\noteLineWidth@kn] (LineL) -- (LineR); |
| 484 |
\foreach \k in {0, 1, ..., \VDNT@dotsNum} {% |
| 485 |
\pgfmathtruncatemacro{\VDNT@halfNum}{\VDNT@dotsNum/2}% |
| 486 |
\def\skipdot{0}% |
| 487 |
\ifnum\i=1 \ifnum\k=\VDNT@halfNum \def\skipdot{1}\fi\fi |
| 488 |
\ifnum\i=#1 \ifnum\k=\VDNT@halfNum \def\skipdot{1}\fi\fi |
| 489 |
\ifnum\skipdot=0 |
| 490 |
\coordinate (DotPos) at (\the\dimexpr\VDNT@Xinterval*\k\relax, \tempY); |
| 491 |
\fill[\VDNT@color] (DotPos) circle [radius=\noteDotsRadius@kn]; |
| 492 |
\fi |
| 493 |
}% |
| 494 |
% 最後に使ったY座標を記録 |
| 495 |
\ifnum\i=#1 \global\VDNT@currentYPos=\tempY\relax \fi |
| 496 |
}% |
| 497 |
\coordinate (BottomMarker) at (\VDNT@Xinterval*\VDNT@dotsNum/2, \VDNT@currentYPos-\noteTriangle@mag@kn*4pt); |
| 498 |
\fill[\VDNT@color] (BottomMarker) -- ++(\noteTriangle@mag@kn*3pt, \noteTriangle@mag@kn*4pt) -- ++(-\noteTriangle@mag@kn*6pt, 0) -- cycle; |
| 499 |
\end{tikzpicture}% |
| 500 |
\egroup% |
| 501 |
\par% |
| 502 |
} |
| 503 |
|
| 504 |
\NewDocumentCommand{\masume}{ s m O{} }{% |
| 505 |
\par\bgroup% |
| 506 |
\pgfkeys{/VDNT, default, #3}% |
| 507 |
\@tempcnta\linewidth% |
| 508 |
\@tempcntb\noteLineDistance@kn% |
| 509 |
\cal@kn@internal% |
| 510 |
\noindent% |
| 511 |
\begin{tikzpicture}[xscale=\VDNT@xscaler] |
| 512 |
\VDNT@currentYPos\z@ |
| 513 |
%%% |
| 514 |
\kn@linecount@internal=#1\relax |
| 515 |
%%% |
| 516 |
\coordinate (TopMarker) at (\VDNT@Xinterval*\VDNT@dotsNum/2, \VDNT@Yinterval+\noteTriangle@mag@kn*4pt); |
| 517 |
\fill[\VDNT@color] (TopMarker) -- ++(\noteTriangle@mag@kn*3pt, -\noteTriangle@mag@kn*4pt) -- ++(-\noteTriangle@mag@kn*6pt, 0) -- cycle; |
| 518 |
\foreach \i in {1, 2, ..., #2} {% |
| 519 |
\xdef\tempY{\the\dimexpr\VDNT@Yinterval*\i\relax} |
| 520 |
\coordinate (LineL) at (0, \tempY); |
| 521 |
\coordinate (LineR) at (\linewidth, \tempY); |
| 522 |
% --- 行番号の描画 --- |
| 523 |
\ifVDNT@shownumber |
| 524 |
\pgfmathtruncatemacro{\VDNT@currentnum}{#2 - \i + 1 } |
| 525 |
\pgfmathtruncatemacro{\rem@notefill}{mod(\VDNT@currentnum,\VDNT@step)} |
| 526 |
\ifnum\rem@notefill=0 |
| 527 |
\node[anchor=east, font=\scriptsize, text=\VDNT@color, overlay] at ([xshift=-\f@size/2pt]LineL) {\VDNT@currentnum}; |
| 528 |
\fi |
| 529 |
\fi |
| 530 |
% -------------------- |
| 531 |
\draw[\VDNT@color, line width=\noteLineWidth@kn] (LineL) -- (LineR); |
| 532 |
\foreach \k in {0, 1, ..., \VDNT@dotsNum} {% |
| 533 |
\pgfmathtruncatemacro{\VDNT@halfNum}{\VDNT@dotsNum/2}% |
| 534 |
\def\skipdot{0}% |
| 535 |
\ifnum\i=1 \ifnum\k=\VDNT@halfNum \def\skipdot{1}\fi\fi |
| 536 |
\ifnum\i=#2 \ifnum\k=\VDNT@halfNum \def\skipdot{1}\fi\fi |
| 537 |
% ------------------ |
| 538 |
\ifnum\i<#2\relax |
| 539 |
\draw[\VDNT@color, line width=\noteLineWidth@kn] (\the\dimexpr\VDNT@Xinterval*\k\relax, \tempY) -- ++(0, \VDNT@Yinterval); |
| 540 |
\fi |
| 541 |
% ------------------ |
| 542 |
\ifnum\skipdot=0 |
| 543 |
\coordinate (DotPos) at (\the\dimexpr\VDNT@Xinterval*\k\relax, \tempY); |
| 544 |
\fill[\VDNT@color] (DotPos) circle [radius=\noteDotsRadius@kn]; |
| 545 |
\fi |
| 546 |
}% |
| 547 |
% 最後に使ったY座標を記録しておく(下の三角用) |
| 548 |
\ifnum\i=#2 \global\VDNT@currentYPos=\tempY\relax \fi |
| 549 |
}% |
| 550 |
\IfBooleanT{#1}{% |
| 551 |
\draw[\VDNT@color, line width=\noteLineWidth@kn*2.5] (0, \the\VDNT@Yinterval) rectangle (\linewidth, \VDNT@currentYPos); |
| 552 |
}% |
| 553 |
\coordinate (BottomMarker) at (\VDNT@Xinterval*\VDNT@dotsNum/2, \VDNT@currentYPos-\noteTriangle@mag@kn*4pt); |
| 554 |
\fill[\VDNT@color] (BottomMarker) -- ++(\noteTriangle@mag@kn*3pt, \noteTriangle@mag@kn*4pt) -- ++(-\noteTriangle@mag@kn*6pt, 0) -- cycle; |
| 555 |
\end{tikzpicture}% |
| 556 |
\egroup% |
| 557 |
\par% |
| 558 |
} |
| 559 |
|
| 560 |
\endinput |
| 561 |
\end{lstlisting} |
| 562 |
\end{document} |