\documentclass[a4paper,12pt]{article} \usepackage{booktabs,tabularray} \usepackage{hyperref} \usepackage{keisennote} \usepackage{listings} \lstset{ basicstyle=\ttfamily\small, keywordstyle=\color{blue}, commentstyle=\color{gray}, stringstyle=\color{red}, breaklines=true, breakatwhitespace=false, columns=flexible } \usepackage{hyperref} \hypersetup{ luatex, pdfencoding=auto, colorlinks=true, linkcolor=black, citecolor=black, urlcolor=DeepSkyBlue3, pdfborder={0 0 0}, } \title{\texttt{keisennote} Package Documentation} \author{Kosei Kawaguchi a.k.a. KKTeX} \date{Version 1.0.4a (2025/10/05)} \begin{document} \begin{titlepage} \maketitle \end{titlepage} \newpage \tableofcontents \newpage \section{Acknowledgements / Credit} This package is based on the code from \href{https://qiita.com/VoD/items/6849e63b978050218d2f}{VoD's Qiita article}, with some improvements. The original author has kindly granted permission to release this as a LaTeX package. \section{Installation} Place \texttt{keisennote.sty} in a directory where LaTeX can find it, e.g., your local \texttt{texmf} tree or alongside your document. Dependencies: \begin{itemize} \item \texttt{xcolor} \item \texttt{tikz} \item \texttt{zref}, \texttt{zref-savepos}, \texttt{fp} \item \texttt{kvoptions} \end{itemize} Load the package: \begin{verbatim} \usepackage{keisennote} \end{verbatim} \section{Package options} This package accepts key--value style options at load time. The option handling is powered by \texttt{kvoptions}, with \texttt{family=kn} and \texttt{prefix=kn@}. All options are declared as string options (accepting any \TeX\ length expression) and are applied during \verb|\ProcessKeyvalOptions*|. The available options and their default values are listed below. \bigskip \begin{center} \begin{tabular}{l l p{.6\linewidth}} \toprule Option name & Default value & Description \\ \midrule \texttt{linewidth} & \texttt{.5truept} & Width of the line used for note drawing. The value is assigned internally to \verb|\noteLineWidth|. Any \TeX\ length (e.g.\ \texttt{1pt}, \texttt{0.6truept}, \texttt{0.2mm}) is accepted. \\ \texttt{radius} & \texttt{.8truept} & Radius of each dot. Internally stored in \verb|\dotsRadius|. \\ \texttt{distance} & \texttt{6truemm} & Spacing between adjacent dots. Internally stored in \verb|\noteLineDistance|. \\ \texttt{triangle} & \texttt{.5pt} & Size of triangular markers. Internally stored in \verb|\VoD@mag|. \\ \bottomrule \end{tabular} \end{center} \bigskip \paragraph{Internal behaviour} \begin{itemize} \item Each option is first stored as a string macro (e.g.\ \verb|\kn@linewidth|), as imposed by \verb|\DeclareStringOption|. The package then assigns it to a \verb|\dimen| register, for example: \begin{lstlisting}[language=TeX] \noteLineWidth=\kn@linewidth\relax \dotsRadius=\kn@radius\relax \noteLineDistance=\kn@distance\relax \VoD@mag=\kn@triangle\relax \end{lstlisting} This conversion ensures that user-supplied expressions such as \texttt{1truept} or \texttt{0.5mm} are properly interpreted as lengths. \item If the package does not perform this assignment automatically, users may do so manually; however, in normal usage this is handled internally. \end{itemize} \paragraph{Examples} \begin{itemize} \item Specify options at package load: \begin{lstlisting}[language=TeX] \usepackage[linewidth=1truept, radius=.6truept, distance=8truemm]{keisennote} \end{lstlisting} \item Modify options afterwards using \verb|\setkeys|: \begin{lstlisting}[language=TeX] \setkeys{kn}{linewidth=0.8pt, distance=5mm} \noteLineWidth=\kn@linewidth\relax % reassign to internal registers if needed \end{lstlisting} \end{itemize} \paragraph{Remarks} \begin{itemize} \item Absolute units such as \texttt{truept} / \texttt{truemm} are used as defaults to avoid driver-dependent scaling. \item No range checks are performed on the option values. Excessively small or negative values may lead to undesirable results. If required, minimum-value guards can be implemented via \verb|\ifdim|. \end{itemize} \section{Commands} \subsection{\texttt{\textbackslash notefill}} \begin{verbatim} \notefill[] \end{verbatim} Fills the current vertical space with ruled notebook lines and dots. \textbf{Example:} \begin{verbatim} \notefill[green] \end{verbatim} \subsection{\texttt{\textbackslash note}} \begin{verbatim} \note{}[] \end{verbatim} Typesets a short ruled block with a specified number of lines. \begin{itemize} \item \texttt{} (mandatory, integer $\ge$ 2): number of ruled lines. \item \texttt{} (optional, default: white!70!black): color of lines and dots. \end{itemize} \textbf{Example:} \begin{verbatim} \note{5}[NavyBlue] \end{verbatim} This produces the following output.\bigskip \note{5}[NavyBlue] \bigskip Inserting \verb|\bigskip| before (and after) using the \verb|\note| command can sometimes improve the appearance. \subsection{\texttt{\textbackslash masumefill}} \begin{verbatim} \masume[] \end{verbatim} Fills the current vertical space with grids and dots. \begin{itemize} \item \texttt{} (optional, default: white!70!black): color of lines and dots. \end{itemize} \textbf{Example:} \begin{verbatim} \notefill[Gray] \end{verbatim} \subsection{\texttt{\textbackslash masume}} \begin{verbatim} \masume{}[] \end{verbatim} Typesets a short grid block with a specified number of lines. \begin{itemize} \item \texttt{} (mandatory, integer $\ge$ 2): number of ruled lines. \item \texttt{} (optional, default: white!70!black): color of lines and dots. \end{itemize} \textbf{Example:} \begin{verbatim} \masume{5}[NavyBlue] \end{verbatim} This produces the following output.\bigskip \masume{5}[NavyBlue] \bigskip Inserting \verb|\bigskip| before (and after) using the \verb|\masume| command can sometimes improve the appearance. \section{Package Parameters} These dimensions can be adjusted: \begin{description} \item[\texttt{\textbackslash SetNoteLineWidth}] You can set the width of note lines : \verb|\SetNoteLineWidth[2mm]| \item[\texttt{\textbackslash SetNoteDotRadius}] You can set the radius of dots. : \verb|\SetNoteDotRadius[1pt]| \item[\texttt{\textbackslash SetNoteLineDistance}] You can set the distance between each lines. \\: \verb|\SetNoteLineDistance[7mm]| \item[\texttt{\textbackslash SetNoteTriangleSize}] You can set the size of triangles. : \verb|\SetNoteTriangleSiz[1pt]| \end{description} If no argument is given, the parameter is reset to its default value. \section{Examples} \subsection{Short Note Block} \begin{verbatim} \note{4} \end{verbatim} \note{4} \newpage \subsection{Full Page Fill} \begin{verbatim} \notefill \end{verbatim} \notefill\newpage \section{License} Released under the \href{https://www.latex-project.org/lppl/}{LaTeX Project Public License (LPPL) 1.3c}. \section{Version History} \begin{itemize} \item \textbf{v1.0.0 (2025/09/13)} --- Initial public release. \item \textbf{v1.0.3 (2025/09/13)} --- KKTeX added \texttt{\textbackslash masume} and \texttt{\textbackslash masumefill}. \item \textbf{v1.0.4 (2025/10/4)} --- KKTeX fixed the problem in \verb|\masumefill| and added some package options and setting commands. \item \textbf{v1.0.4a (2025/10/5)} --- Added some descriptions about new package options. \end{itemize} \section{Source Code} \begin{lstlisting} \ProvidesPackage{keisennote}[2025/10/05, v1.0.4a] \RequirePackage[dvipsnames, svgnames, x11names]{xcolor} \RequirePackage{zref, zref-savepos, fp} \RequirePackage{tikz} \RequirePackage{kvoptions} \SetupKeyvalOptions{% family=kn,% prefix=kn@% } \newdimen\noteLineWidth \noteLineWidth=.5truept \newdimen\dotsRadius \dotsRadius=.8truept \newdimen\noteLineDistance \noteLineDistance=6truemm \newdimen\VoD@mag \VoD@mag=.5pt %%%パッケージオプションの宣言 \DeclareStringOption[.5truept]{linewidth}% 線の太さ \DeclareStringOption[.8truept]{radius}% ドットの大きさ \DeclareStringOption[6truemm]{distance}% ドットの間隔 \DeclareStringOption[.5pt]{triangle}% 三角形の大きさ \ProcessKeyvalOptions* % オプション適用 %%%オプションの反映 \setlength{\noteLineWidth}{\kn@linewidth} \setlength{\dotsRadius}{\kn@radius} \setlength{\noteLineDistance}{\kn@distance} \setlength{\VoD@mag}{\kn@triangle} %%%途中でパラメータ変更ができるように \NewDocumentCommand{\SetNoteLineWidth}{O{.5truept}}{% \setlength{\noteLineWidth}{#1} } \NewDocumentCommand{\SetNoteDotRadius}{O{.8truept}}{% \setlength{\dotsRadius}{#1} } \NewDocumentCommand{\SetNoteLineDistance}{O{6truemm}}{% \setlength{\noteLineDistance}{#1} } \NewDocumentCommand{\SetNoteTriangleSize}{O{.5pt}}{% \setlength{\VoD@mag}{#1} } %%%必要な内部レジスタの用意 \newdimen\VDNT@currentXPos \newdimen\VDNT@currentYPos \newdimen\VDNT@Xinterval \newdimen\VDNT@Yinterval \newdimen\VDNT@notegoal %%% \notefillで用いる座標管理用カウンタの準備 \def\VDNT@pkgname{vodnote} \global\newcount\VDNT@uniqe %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% \notefill の定義 \NewDocumentCommand{\notefill}{ O{white!70!black} }{\par\bgroup \parindent\z@ %%罫線間隔の算出 \@tempcnta\linewidth \@tempcntb\noteLineDistance \FPeval\VDNT@dotsNum{round(round(((\the)\@tempcnta/(\the)\@tempcntb)/2:0)*2:0)}% \VDNT@Xinterval\dimexpr(\linewidth)/\VDNT@dotsNum\relax \VDNT@Yinterval\VDNT@Xinterval %%上端の座標取得 \zsaveposy{\VDNT@pkgname.\the\VDNT@uniqe.TopPos}% %%下端の座標取得 \leavevmode\vfill\leavevmode \zsaveposy{\VDNT@pkgname.\the\VDNT@uniqe.BottomPos}% %%ノート罫線描画幅の決定 \VDNT@notegoal=\dimexpr \zposy{\VDNT@pkgname.\the\VDNT@uniqe.TopPos}sp -\zposy{\VDNT@pkgname.\the\VDNT@uniqe.BottomPos}sp \relax %%ノート罫線描画 \noindent\smash{% \begin{tikzpicture}[xscale=0.996] \VDNT@currentYPos\z@ \fill[#1] (\VDNT@Xinterval*\VDNT@dotsNum/2,\VDNT@currentYPos+\VoD@mag*4pt) -- ++(\VoD@mag*3pt,-\VoD@mag*4pt) -- ++(-\VoD@mag*6pt,0) -- cycle; \@whiledim\VDNT@currentYPos<\VDNT@notegoal\do{ \VDNT@currentXPos\z@ \draw[#1,line width=\noteLineWidth] (0,\VDNT@currentYPos) -- (\linewidth,\VDNT@currentYPos); \foreach \k in{0,1,...,\VDNT@dotsNum}{% \VDNT@currentXPos=\dimexpr\VDNT@Xinterval*\k\relax \fill[#1] (\VDNT@currentXPos,\VDNT@currentYPos) circle [radius=\dotsRadius]; } \advance\VDNT@currentYPos\VDNT@Yinterval\relax } \fill[#1] (\VDNT@Xinterval*\VDNT@dotsNum/2,\VDNT@currentYPos-\VDNT@Yinterval-\VoD@mag*4pt) -- ++(\VoD@mag*3pt,\VoD@mag*4pt) -- ++(-\VoD@mag*6pt,0) -- cycle; \end{tikzpicture}% }% \egroup %%座標管理用カウンタのインクリメント \global\advance\VDNT@uniqe\@ne \par } %%% \note の定義(2以上の整数を引数に) \NewDocumentCommand{\note}{ m O{white!70!black} }{\par\bgroup %%罫線間隔の算出 \@tempcnta\linewidth \@tempcntb\noteLineDistance \FPeval\VDNT@dotsNum{round(round(((\the)\@tempcnta/(\the)\@tempcntb)/2:0)*2:0)}% \VDNT@Xinterval\dimexpr\linewidth/\VDNT@dotsNum\relax \VDNT@Yinterval\VDNT@Xinterval %%ノート罫線描画 \noindent \begin{tikzpicture}[xscale=0.996] \VDNT@currentYPos\z@ \fill[#2] (\VDNT@Xinterval*\VDNT@dotsNum/2,\VDNT@currentYPos+\VDNT@Yinterval+\VoD@mag*4pt) -- ++(\VoD@mag*3pt,-\VoD@mag*4pt) -- ++(-\VoD@mag*6pt,0) -- cycle; %上の三角形 \foreach \i in{1,2,...,#1}{ \VDNT@currentXPos\z@ \global\VDNT@currentYPos=\dimexpr\VDNT@Yinterval*\i\relax \draw[#2,line width=\noteLineWidth] (0,\VDNT@currentYPos) -- (\linewidth,\VDNT@currentYPos); \foreach \k in{0,1,...,\VDNT@dotsNum}{ \VDNT@currentXPos=\dimexpr\VDNT@Xinterval*\k\relax \fill[#2] (\VDNT@currentXPos,\VDNT@currentYPos) circle [radius=\dotsRadius]; } } \fill[#2] (\VDNT@Xinterval*\VDNT@dotsNum/2,\VDNT@currentYPos-\VoD@mag*4pt) -- ++(\VoD@mag*3pt,\VoD@mag*4pt) -- ++(-\VoD@mag*6pt,0) -- cycle; %下の三角形 \end{tikzpicture}% \egroup \par } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NewDocumentCommand{\masumefill}{ O{white!70!black} }{\par\bgroup \parindent\z@ %%罫線間隔の算出 \@tempcnta\linewidth \@tempcntb\noteLineDistance \FPeval\VDNT@dotsNum{round(round(((\the)\@tempcnta/(\the)\@tempcntb)/2:0)*2:0)}% \VDNT@Xinterval\dimexpr(\linewidth)/\VDNT@dotsNum\relax \VDNT@Yinterval\VDNT@Xinterval %%上端の座標取得 \zsaveposy{\VDNT@pkgname.\the\VDNT@uniqe.TopPos}% %%下端の座標取得 \leavevmode\vfill\leavevmode \zsaveposy{\VDNT@pkgname.\the\VDNT@uniqe.BottomPos}% %%ノート罫線描画幅の決定 \VDNT@notegoal=\dimexpr \zposy{\VDNT@pkgname.\the\VDNT@uniqe.TopPos}sp -\zposy{\VDNT@pkgname.\the\VDNT@uniqe.BottomPos}sp \relax %%ノート罫線描画 \noindent\smash{% \begin{tikzpicture}[xscale=0.996] \VDNT@currentYPos\z@ \fill[#1] (\VDNT@Xinterval*\VDNT@dotsNum/2,\VDNT@currentYPos+\VoD@mag*4pt) -- ++(\VoD@mag*3pt,-\VoD@mag*4pt) -- ++(-\VoD@mag*6pt,0) -- cycle; \@whiledim\VDNT@currentYPos<\VDNT@notegoal\do{ \VDNT@currentXPos\z@ \draw[#1,line width=\noteLineWidth] (0,\VDNT@currentYPos) -- (\linewidth,\VDNT@currentYPos); \foreach \k in{0,1,...,\VDNT@dotsNum}{% \VDNT@currentXPos=\dimexpr\VDNT@Xinterval*\k\relax \draw[#1,line width=\noteLineWidth] (\VDNT@currentXPos,0) -- (\VDNT@currentXPos,\VDNT@currentYPos); \fill[#1] (\VDNT@currentXPos,\VDNT@currentYPos) circle [radius=\dotsRadius]; } \advance\VDNT@currentYPos\VDNT@Yinterval\relax } \fill[#1] (\VDNT@Xinterval*\VDNT@dotsNum/2,\VDNT@currentYPos-\VDNT@Yinterval-\VoD@mag*4pt) -- ++(\VoD@mag*3pt,\VoD@mag*4pt) -- ++(-\VoD@mag*6pt,0) -- cycle; \end{tikzpicture}% }% \egroup %%座標管理用カウンタのインクリメント \global\advance\VDNT@uniqe\@ne \par } \NewDocumentCommand{\masume}{ m O{white!70!black} }{\par\bgroup %%罫線間隔の算出 \@tempcnta\linewidth \@tempcntb\noteLineDistance \FPeval\VDNT@dotsNum{round(round(((\the)\@tempcnta/(\the)\@tempcntb)/2:0)*2:0)}% \VDNT@Xinterval\dimexpr\linewidth/\VDNT@dotsNum\relax \VDNT@Yinterval\VDNT@Xinterval %%ノート罫線描画 \noindent \begin{tikzpicture}[xscale=0.996] \VDNT@currentYPos\z@ \fill[#2] (\VDNT@Xinterval*\VDNT@dotsNum/2,\VDNT@currentYPos+\VDNT@Yinterval+\VoD@mag*4pt) -- ++(\VoD@mag*3pt,-\VoD@mag*4pt) -- ++(-\VoD@mag*6pt,0) -- cycle; %上の三角形 \foreach \i in{1,2,...,#1}{ \VDNT@currentXPos\z@ \global\VDNT@currentYPos=\dimexpr\VDNT@Yinterval*\i\relax \draw[#2,line width=\noteLineWidth] (0,\VDNT@currentYPos) -- (\linewidth,\VDNT@currentYPos); \foreach \k in{0,1,...,\VDNT@dotsNum}{ \VDNT@currentXPos=\dimexpr\VDNT@Xinterval*\k\relax \draw[#2,line width=\noteLineWidth] (\VDNT@currentXPos,\VDNT@Yinterval) -- (\VDNT@currentXPos,\VDNT@Yinterval*#1); \fill[#2] (\VDNT@currentXPos,\VDNT@currentYPos) circle [radius=\dotsRadius]; } } \fill[#2] (\VDNT@Xinterval*\VDNT@dotsNum/2,\VDNT@currentYPos-\VoD@mag*4pt) -- ++(\VoD@mag*3pt,\VoD@mag*4pt) -- ++(-\VoD@mag*6pt,0) -- cycle; %下の三角形 \end{tikzpicture}% \egroup \par } \endinput \end{lstlisting} \end{document}