summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/musikui
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/musikui
Initial commit
Diffstat (limited to 'macros/latex/contrib/musikui')
-rw-r--r--macros/latex/contrib/musikui/README.txt8
-rw-r--r--macros/latex/contrib/musikui/kake.pdfbin0 -> 393969 bytes
-rw-r--r--macros/latex/contrib/musikui/musikui.pdfbin0 -> 46129 bytes
-rw-r--r--macros/latex/contrib/musikui/musikui.sty294
-rw-r--r--macros/latex/contrib/musikui/musikui.tex207
-rw-r--r--macros/latex/contrib/musikui/wari.pdfbin0 -> 394075 bytes
6 files changed, 509 insertions, 0 deletions
diff --git a/macros/latex/contrib/musikui/README.txt b/macros/latex/contrib/musikui/README.txt
new file mode 100644
index 0000000000..8173f4ff22
--- /dev/null
+++ b/macros/latex/contrib/musikui/README.txt
@@ -0,0 +1,8 @@
+musikui
+This package is for easy expression of arithmetical restorations with LaTeX.
+
+Requirements
+This package requires graphics" package.
+
+License
+The LaTeX Project Public License \ No newline at end of file
diff --git a/macros/latex/contrib/musikui/kake.pdf b/macros/latex/contrib/musikui/kake.pdf
new file mode 100644
index 0000000000..20bd0462f6
--- /dev/null
+++ b/macros/latex/contrib/musikui/kake.pdf
Binary files differ
diff --git a/macros/latex/contrib/musikui/musikui.pdf b/macros/latex/contrib/musikui/musikui.pdf
new file mode 100644
index 0000000000..12b31e36da
--- /dev/null
+++ b/macros/latex/contrib/musikui/musikui.pdf
Binary files differ
diff --git a/macros/latex/contrib/musikui/musikui.sty b/macros/latex/contrib/musikui/musikui.sty
new file mode 100644
index 0000000000..5c142576ae
--- /dev/null
+++ b/macros/latex/contrib/musikui/musikui.sty
@@ -0,0 +1,294 @@
+%
+% This is file 'musikui.sty'.
+%
+% Author
+% Naoki Kaneko
+% License
+% The LaTeX Project Public License
+
+%% package declaration
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{musikui}[2018/04/25 v1]
+\def\mk@pkgname{musikui}
+\RequirePackage{graphicx}
+
+%--------------------------------------- general
+
+%% unique tokens
+\def\mk@end{\mk@end@}
+
+%% variables
+\newdimen\mk@width
+\newdimen\mk@halfwidth
+\newdimen\mk@height
+\newdimen\mk@depth
+\newdimen\mk@hgap
+\newdimen\mk@vgap
+\newdimen\mk@rule
+\newdimen\mk@dima
+\newif\ifmk@g@box@used
+\newif\ifmk@graphicx
+\newbox\mk@product
+\newbox\mk@product@a
+\newbox\mk@product@b
+\newbox\mk@quotient@a
+\newbox\mk@quotient@b
+\newbox\mk@whole
+\newbox\mk@boxa
+\newbox\mk@boxb
+\newcounter{mk@counter@kake}
+\setcounter{mk@counter@kake}{0}
+\newcounter{mk@counter@wari}
+\setcounter{mk@counter@wari}{0}
+\let\mk@cell@proc\relax
+
+%% switch 'mk@graphicx'
+\AtBeginDocument{%
+ \@ifpackageloaded{graphicx}{\mk@graphicxtrue}{}}
+
+%% \mk@foreach@cell\CS{...&...&...}
+\def\mk@foreach@cell#1#2{%
+ \def\mk@cell@proc{#1}%
+ \let\mk@next\mk@foreach@cell@a
+ \mk@next#2&\mk@end&}
+\def\mk@foreach@cell@a#1&{%
+ \def\mk@tmpa{#1}\def\mk@tmpb{\mk@end}%
+ \ifx\mk@tmpa\mk@tmpb
+ \let\mk@next\relax
+ \else
+ \mk@cell@proc{#1}%
+ \fi
+ \mk@next}
+
+%% \mk@fit@width{<width>}{<text>}
+\def\mk@fit@width#1#2{%
+ \sbox\mk@boxb{#2}%
+ \ifdim\wd\mk@boxb>#1\relax
+ \ifmk@graphicx
+ \resizebox{#1}{\height}{\usebox\mk@boxb}%
+ \else
+ \hb@xt@#1{\hss\usebox\mk@boxb\hss}%
+ \fi
+ \else
+ \hb@xt@#1{\hfil\usebox\mk@boxb\hfil}%
+ \fi}
+
+%--------------------------------------- public parameters
+
+% NOTE: These parameters are not lengths but macros.
+
+%%<*> \musiwidth
+% The width of a hole.
+\newcommand*{\musiwidth}{1.2em}
+
+%%<*> \musiheight
+% The height of a hole.
+\newcommand*{\musiheight}{0.96em}
+
+%%<*> \musidepth
+% The depth of a hole.
+\newcommand*{\musidepth}{0.24em}
+
+%%<*> \musihgap
+% The horizonal gap between holes.
+\newcommand*{\musihgap}{0.4em}
+
+%%<*> \musivgap
+% The vertical gap between holes.
+\newcommand*{\musivgap}{0.4em}
+
+%%<*> \musirule
+% The rule width.
+\newcommand*{\musirule}{0.4pt}
+
+%%<*> \musiopsymbol
+% The operator symbol.
+\newcommand*{\musiopsymbol}{$\times$}
+
+%%<)> \musiwarikakko
+\newcommand*{\musiwarikakko}{\Big)}
+%--------------------------------------- cells
+
+%% variables
+\newdimen\mk@org@rule
+\newdimen\mk@org@sep
+
+%% \mk@eaten{<text>}
+\def\mk@eaten#1{%
+ \mk@frame@box{\mk@fit@width{\mk@width}{#1}}}
+
+%% \mk@noneaten{<text>}
+\def\mk@noneaten#1{%
+ \mk@plain@box{\mk@fit@width{\mk@width}{#1}}}
+
+%% \mk@halfeaten{<text>}
+\def\mk@halfeaten#1{%
+ \mk@frame@box{\mk@fit@width{\mk@halfwidth}{#1}}}
+
+%% \mk@halfnoneaten{<text>}
+\def\mk@halfnoneaten#1{%
+ \mk@plain@box{\mk@fit@width{\mk@halfwidth}{#1}}}
+
+%% \mk@hhalfeaten{<textL>}{<textR>}
+\def\mk@hhalfeaten#1#2{%
+ \mk@frame@box{\mk@fit@width{\mk@halfwidth}{#1}}%
+ \kern-\mk@rule
+ \mk@frame@box{\mk@fit@width{\mk@halfwidth}{#2}}}
+
+%% \mk@hhalfnoneaten{<textL>}{<textR>}
+\def\mk@hhalfnoneaten#1#2{%
+ \mk@plain@box{\mk@fit@width{\mk@halfwidth}{#1}}%
+ \kern-\mk@rule
+ \mk@plain@box{\mk@fit@width{\mk@halfwidth}{#2}}}
+
+%% \mk@frame@box{<text>}
+\def\mk@frame@box#1{%
+ \global\mk@g@box@usedtrue
+ \begingroup
+ \mk@org@rule\fboxrule \mk@org@sep\fboxsep
+ \fboxrule\mk@rule \fboxsep\z@
+ \fbox{\fboxrule\mk@org@rule \fboxsep\mk@org@sep
+ \raisebox{\z@}[\mk@height][\mk@depth]{#1}}%
+ \endgroup}
+
+%% \mk@plain@box{<text>}
+\def\mk@plain@box#1{%
+ \global\mk@g@box@usedtrue
+ \leavevmode \kern\mk@rule
+ \raisebox{\z@}[\mk@height][\mk@depth]{#1}%
+ \kern\mk@rule}
+
+%--------------------------------------- entire constructino
+
+%% \mk@initialize
+\def\mk@initialize{%
+ % internal parameters
+ \setlength{\mk@hgap}{\musihgap}%
+ \setlength{\mk@vgap}{\musivgap}%
+ \setlength{\mk@rule}{\musirule}%
+ \setlength{\mk@width}{\musiwidth}%
+ \advance\mk@width-2\mk@rule
+ \mk@halfwidth.5\mk@width
+ \advance\mk@halfwidth-.5\mk@rule
+ \setlength{\mk@height}{\musiheight}%
+ \advance\mk@height-\mk@rule
+ \setlength{\mk@depth}{\musidepth}%
+ \advance\mk@depth-\mk@rule
+ \setbox\mk@product\box\voidb@x
+ % commands used inside musikui
+ \let\eaten\mk@eaten
+ \let\noneaten\mk@noneaten
+ \let\halfeaten\mk@halfeaten
+ \let\halfnoneaten\mk@halfnoneaten
+ \let\hhalfeaten\mk@hhalfeaten
+ \let\hhalfnoneaten\mk@hhalfnoneaten
+ \let\kake\mk@kake
+ \let\wari\mk@wari
+ \let\musi\mk@musi
+ \let\bubunsen\mk@bubunsen
+ \let\sen\mk@sen}
+
+\def\mk@put@cell#1{%
+ \global\mk@g@box@usedfalse
+ \sbox\mk@boxa{\ignorespaces#1\unskip}%
+ \ifmk@g@box@used
+ \usebox\mk@boxa
+ \else
+ \mk@noneaten{\usebox\mk@boxa}%
+ \fi
+ \hskip\mk@hgap}
+
+%% \mk@kake{<multiplicand>}{<multiplier>}{<product>}
+\def\mk@kake#1#2#3{%
+ \setcounter{mk@counter@kake}{0}
+ \setcounter{mk@counter@wari}{0}
+ \stepcounter{mk@counter@kake}
+ \sbox\mk@product@a{%
+ \hskip\mk@hgap \mk@foreach@cell\mk@put@cell{#3}}%
+ \let\mk@product\mk@product@a
+ \hb@xt@\wd\mk@product{%
+ \hfil \mk@foreach@cell\mk@put@cell{#1}}%
+ \nointerlineskip
+ \vskip\mk@vgap
+ \hb@xt@\wd\mk@product{%
+ \hskip\mk@hgap
+ \hb@xt@\mk@width{\hss\musiopsymbol\hss}%
+ \hfil \mk@foreach@cell\mk@put@cell{#2}}%
+ \vskip\mk@vgap
+ \hrule\@height\mk@rule\@depth\z@
+ \vskip\mk@vgap}
+
+%% \mk@wari{<dividend>}{<divide>}{<quotient>}
+\def\mk@wari#1#2#3{%
+ \setcounter{mk@counter@kake}{0}
+ \setcounter{mk@counter@wari}{0}
+ \stepcounter{mk@counter@wari}
+ \sbox\mk@quotient@a{\smash{\musiwarikakko}\hskip\mk@hgap \mk@foreach@cell\mk@put@cell{#1}}
+ \sbox\mk@quotient@b{%
+ \mk@foreach@cell\mk@put@cell{#2}\copy\mk@quotient@a}%
+ \hb@xt@\wd\mk@quotient@b{%
+ \hfil \mk@foreach@cell\mk@put@cell{#3}}%
+ \nointerlineskip%
+ \vskip\mk@vgap%
+ \mk@sen%
+ \copy\mk@quotient@b%
+ \nointerlineskip
+ \vskip\mk@vgap}
+
+%% \mk@musi{<content>}{<trail-count>}
+\def\mk@musi#1#2{%
+ \ifvoid\mk@product\else
+ {\ifnum \themk@counter@wari=1 \let\mk@product\mk@quotient@b
+ \else \let\mk@product\mk@product@a \fi
+ \hb@xt@\wd\mk@product{%
+ \hfil \mk@foreach@cell\mk@put@cell{#1}%
+ \advance\mk@width2\mk@rule
+ \advance\mk@width\mk@hgap
+ \hskip#2\mk@width}%
+ \nointerlineskip
+ \vskip\mk@vgap}
+ \fi}
+
+%% \mk@sen
+\def\mk@sen{%
+ \ifnum \themk@counter@wari=1 \let\mk@product@R\mk@quotient@a
+ \else \let\mk@product@R\mk@product@a \fi
+ \ifnum \themk@counter@wari=1 \let\mk@product\mk@quotient@b
+ \else \let\mk@product\mk@product@a \fi
+ \hb@xt@\wd\mk@product{\hfil%
+ \vrule\@height\mk@rule width \wd\mk@product@R}%
+ \nointerlineskip
+ \vskip\mk@vgap}
+
+%% \mk@bubunsen{<rule-count>}{<trail-count>}
+\def\mk@bubunsen#1#2{%
+ \ifnum \themk@counter@wari=1 \let\mk@product\mk@quotient@b
+ \else \let\mk@product\mk@product@a \fi
+ \hb@xt@\wd\mk@product{\hfil
+ \advance\mk@width2\mk@rule
+ \advance\mk@width\mk@hgap
+ \mk@dima#1\mk@width \advance\mk@dima\mk@hgap
+ \vrule\@height\mk@rule\@width\mk@dima
+ \hskip#2\mk@width}%
+ \nointerlineskip
+ \vskip\mk@vgap}
+
+%% \mk@finalize
+\def\mk@finalize{%
+%\typeout{size=(\the\ht\mk@product+\the\dp\mk@product)x\the\wd\mk@product}%
+ \box\mk@product@a}
+
+%--------------------------------------- public interface
+
+%%<*> \begin{musikui}...\end{musikui}
+\newenvironment{musikui}{%
+\leavevmode
+ \mk@initialize
+ \setbox\mk@whole\vbox\bgroup}%
+ {\mk@finalize
+ \egroup
+ \box\mk@whole}
+
+%--------------------------------------- all done
+\endinput
+%% EOF \ No newline at end of file
diff --git a/macros/latex/contrib/musikui/musikui.tex b/macros/latex/contrib/musikui/musikui.tex
new file mode 100644
index 0000000000..d5dfd24535
--- /dev/null
+++ b/macros/latex/contrib/musikui/musikui.tex
@@ -0,0 +1,207 @@
+\documentclass[dvipdfmx]{article}
+
+\usepackage{musikui}
+\usepackage{listings}
+\usepackage[dvipdfmx]{hyperref}
+\usepackage{longtable}
+
+\title{The musikui package v1}
+\author{Naoki Kaneko}
+\date{2018/04/25}
+\begin{document}
+\maketitle
+
+This package is for easy expression of arithmetical restorations with \LaTeX{}.
+
+\begin{center}
+\begin{musikui}
+\wari{\eaten{}&\eaten{}&\eaten{}&\eaten{}&\eaten{}&\eaten{}&\eaten{}&\eaten{}}
+{\eaten{}&\eaten{}&\eaten{}}
+{\eaten{}&7&\eaten{}&\eaten{}&\eaten{}}
+\musi{\eaten{}&\eaten{}&\eaten{}&\eaten{}}{4}
+\sen
+\musi{\eaten{}&\eaten{}&\eaten{}}{3}
+\musi{\eaten{}&\eaten{}&\eaten{}}{3}
+\sen
+\musi{\eaten{}&\eaten{}&\eaten{}&\eaten{}}{2}
+\musi{\eaten{}&\eaten{}&\eaten{}}{2}
+\sen
+\musi{\eaten{}&\eaten{}&\eaten{}&\eaten{}}{0}
+\musi{\eaten{}&\eaten{}&\eaten{}&\eaten{}}{0}
+\sen
+\musi{0}{0}
+\end{musikui}
+\end{center}
+
+The package is maintained on GitHub:
+\begin{itemize}
+\item \url{https://github.com/puripuri2100/musikui.sty}
+\end{itemize}
+\section{Package read}
+Read using \verb|\usepackage| command. There is no option.
+
+\begin{lstlisting}[language=TeX]
+\usepackage{musikui}
+\end{lstlisting}
+\section{Dependent package}
+graphics package
+
+\section{License}
+The \LaTeX{} Project Public License
+\section{Provide command}
+\subsection{Commands related to composition}
+\begin{lstlisting}[language=TeX]
+\kake{<multiplicand>}{<multiplier>}{<product>}
+\wari{<dividend>}{<divide>}{<quotient>}
+\musi{<holes>}{<distance from the right end>}
+\sen
+\bubunsen{<length>}{<distance from the right end>}
+\end{lstlisting}
+
+\subsection{Commands related to holes}
+\begin{lstlisting}[language=TeX]
+\eaten{<numbers etc.>}
+\noneaten{<numbers etc.>}
+\halfeaten{<numbers etc.>}
+\halfnoneaten{<numbers etc.>}
+\hhalfeaten{<numbers etc.>}
+\hhalfnoneaten{<numbers etc.>}
+\end{lstlisting}
+
+\section{The role of each command}
+The role of each command is shown in Table \ref{yakuwari}.
+\begin{longtable}[h]{rp{20em}}
+\caption{\label{yakuwari}}\\
+\verb|\kake|&Outputs \verb|<multiplicand>| \verb|<multiplier>| \verb|<product>| of multiplication arithmetical restorations calculation.\\
+\verb|\wari|&Outputs \verb|<dividend>| \verb|<divide>| \verb|<quotient>| of division arithmetical restorations calculation.\\
+\verb|\musi| &Outputs \verb|<holes> <distance from the right end> |.\\
+\verb|\sen|&line\\
+\verb|\bubunsen|&Line of the specified length\\
+\verb|\eaten|&normal hole\\
+\verb|\noneaten| &hole without a line \\
+\verb|\halfeaten| &Half the width hole of \verb|\eaten|.\\
+\verb|\halfnoneaten| &Hole without a line with half width of \verb|\eaten|.\\
+\verb|\hhalfeaten| &Two holes with \verb|\harleaten| side by side.\\
+\verb|\hhalfnoneaten| &\verb|\hhalfeaten| line without a hole
+\end{longtable}
+
+\section{Notation}
+Use one musikui environment per an arithmetical restorations.
+For the representation part of the hole, a hole and a hole (or a number) are connected by ``\verb|&|".
+After using \verb|\kake| or \verb|\wari|, you just line \verb|\musi| and \verb|\sen| like the hole counting you want to express.
+An example of division and multiplication is given below.
+
+\begin{longtable}[h]{l|l}
+\begin{lstlisting}[language=TeX]
+\begin{musikui}
+\kake{8&\eaten{}&6&\eaten{}}
+{\eaten{}&\eaten{}}
+{\eaten{}&\eaten&\eaten{}&\eaten{}&\eaten{}}
+\musi{\eaten{}&6&\eaten{}&\eaten{}&\eaten{}}{0}
+\musi{\eaten{}&\eaten{}&\eaten{}&6}{1}
+\sen
+\end{musikui}
+\end{lstlisting}
+&
+\begin{musikui}
+\kake{8&\eaten{}&6&\eaten{}}
+{\eaten{}&\eaten{}}
+{\eaten{}&\eaten&\eaten{}&\eaten{}&\eaten{}}
+\musi{\eaten{}&6&\eaten{}&\eaten{}&\eaten{}}{0}
+\musi{\eaten{}&\eaten{}&\eaten{}&6}{1}
+\sen
+\end{musikui}
+\\
+\begin{lstlisting}[language=TeX]
+\begin{musikui}
+\wari{\eaten{}&\eaten{}&\eaten{}&\eaten{}}
+{\eaten{}&\eaten{}}
+{\eaten{}&\eaten}
+\musi{\eaten{}&\eaten{}}{1}
+\sen
+\musi{8&\eaten{}}{0}
+\musi{\eaten{}&\eaten{}}{0}
+\sen
+\musi{\eaten{}}{0}
+\end{musikui}
+\end{lstlisting}
+&
+\begin{musikui}
+\wari{\eaten{}&\eaten{}&\eaten{}&\eaten{}}
+{\eaten{}&\eaten{}}
+{\eaten{}&\eaten}
+\musi{\eaten{}&\eaten{}}{1}
+\sen
+\musi{8&\eaten{}}{0}
+\musi{\eaten{}&\eaten{}}{0}
+\sen
+\musi{\eaten{}}{0}
+\end{musikui}
+\\
+\begin{lstlisting}[language=TeX]
+\begin{musikui}
+\wari{\eaten{}&\eaten{}&\eaten{}&\eaten{}}
+{\eaten{}&\eaten{}}
+{\eaten{}&\eaten}
+\musi{\eaten{}&\eaten{}}{1}
+\bubunsen{4}{0}
+\musi{8&\eaten{}}{0}
+\musi{\eaten{}&\eaten{}}{0}
+\bubunsen{2}{0}
+\musi{\eaten{}}{0}
+\end{musikui}
+\end{lstlisting}
+&
+\begin{musikui}
+\wari{\eaten{}&\eaten{}&\eaten{}&\eaten{}}
+{\eaten{}&\eaten{}}
+{\eaten{}&\eaten}
+\musi{\eaten{}&\eaten{}}{1}
+\bubunsen{4}{0}
+\musi{8&\eaten{}}{0}
+\musi{\eaten{}&\eaten{}}{0}
+\bubunsen{2}{0}
+\musi{\eaten{}}{0}
+\end{musikui}
+\end{longtable}
+
+\section{Customize}
+You can change the value of arithmetical restorations using \verb|\renewcommand*|.
+
+\begin{lstlisting}[language=TeX]
+\renewcommand*{\musiwidth}{2em}
+\end{lstlisting}
+The values whose roles and default values can be changed are shown in Table \ref{kiteiti}.
+
+\begin{longtable}[h]{lll}
+\caption{\label{kiteiti}}\\
+\verb|\musiwidth|&hole width&1.2em\\
+\verb|\musiheight|&hole height&0.96em\\
+\verb|\musidepth|&hole depth&0.24em\\
+\verb|\musihgap|&distance between hole and hole&0.4em\\
+\verb|\musivgap|&distance between hole and line&0.4em\\
+\verb|\musirule|&line width&0.4pt\\
+\verb|\musiopsymbol|&multiplication sign&\verb|$\times$|\\
+\verb|\musiwarikakko|&divide symbol&\verb|\Big)|
+\end{longtable}
+
+\section{Summary}
+If all of the above is taken into the drawing, it will be Figure \ref{fig:one} and Figure \ref{fig:two}.
+
+\begin{figure}[htbp]
+ \begin{minipage}{0.5\hsize}
+ \begin{center}
+ \includegraphics[width=60mm]{kake.pdf}
+ \end{center}
+ \caption{multiplication}
+ \label{fig:one}
+ \end{minipage}
+ \begin{minipage}{0.5\hsize}
+ \begin{center}
+ \includegraphics[width=60mm]{wari.pdf}
+ \end{center}
+ \caption{division}
+ \label{fig:two}
+ \end{minipage}
+\end{figure}
+\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/musikui/wari.pdf b/macros/latex/contrib/musikui/wari.pdf
new file mode 100644
index 0000000000..8a9b82e517
--- /dev/null
+++ b/macros/latex/contrib/musikui/wari.pdf
Binary files differ