Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created November 10, 2017 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zr-tex8r/7af2057302d82df842f062ea6ec7b5b7 to your computer and use it in GitHub Desktop.
Save zr-tex8r/7af2057302d82df842f062ea6ec7b5b7 to your computer and use it in GitHub Desktop.
LaTeX:1TeXのソースを画期的な新記法で掲載する
%%
%% This is file 'tc1verbatim.sty'.
%%
%% Copyright (c) 2017 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
%% This package is distributed under the MIT License.
%%
%% package declaration
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tc1verbatim}[2017/11/11 v1.1]
\def\tczov@pkgname{tc1verbatim}
%--------------------------------------- general
%% packages
\RequirePackage{verbatim}[2003/08/22]% 1.5q
\providecommand\bxDebug[1]{}
%% unique tokens
%% variables
\newcount\xx@cnta
%--------------------------------------- options
%% declarations
%% dispatch
%--------------------------------------- one-verbatim
%%<*> \begin{onevervatim}
\newenvironment{oneverbatim}%
{\xx@one@active\verbatim}%
{\endverbatim}
%%<*> \begin{onevervatim*}
\catcode`*=11
\newenvironment{oneverbatim*}%
{\xx@one@active\verbatim*}%
{\endverbatim*}
\catcode`*=12
%%<*> \oneverbatiminput{<file>}
\newcommand*\oneverbatiminput{%
\@ifstar{\xx@oneverbatiminput@a*}{\xx@oneverbatiminput@a{}}}
\def\xx@oneverbatiminput@a#1#2{%
\begingroup
\xx@one@active
\verbatiminput#1{#2}%
\endgroup}
%% \xx@one@active
% Mekes '1' do \xx@one.
\begingroup\lccode`\~=`1\lowercase{%
\gdef\xx@one@active{%
\catcode`1=\active \let~\xx@one}
}\endgroup
%% \xx@one
% The one.
\def\xx@one{%
\xx@cnta\@ne
\futurelet\xx@tok\xx@one@a}
\def\xx@one@a{%
\ifx\xx@one\xx@tok
\expandafter\xx@one@b
\else
\onetallyof\xx@cnta
\fi}
\def\xx@one@b#1{%
\advance\xx@cnta\@ne
\futurelet\xx@tok\xx@one@a}
%--------------------------------------- one-tally
%%<*> \onetallyof{<number>}
\DeclareRobustCommand*\onetallyof[1]{%
\begingroup
\xx@cnta=#1\relax
\ifnum\xx@cnta<\@ne % no-op
\else\ifnum\xx@cnta=\@ne 1% simple
\else \xx@onetallyof@a
\fi\fi
\endgroup}
\def\xx@onetallyof@a{%
\ifnum\xx@cnta=\z@
\expandafter\@gobble
\else\ifnum\xx@cnta>9
\advance\xx@cnta-10
1\xx@nine@ones
\else\ifnum\xx@cnta>4
\advance\xx@cnta-5
1\xx@four@ones
\else
\advance\xx@cnta-1
1%
\fi\fi\fi
\xx@onetallyof@a}
%% \onetally{<counter>}
\newcommand*\onetally[1]{%
\onetallyof{\the\@nameuse{c@#1}}}
%% \xx@nine@ones
\def\xx@nine@ones{%
\begingroup
\xx@prepare@ones{0.3}%
\setbox\z@\hb@xt@2\wd\tw@{1\hss1\hss1\hss}%
\vbox{\copy\z@\kern\z@\copy\z@\kern\z@\copy\z@}%
\endgroup}
%% \xx@four@ones
\def\xx@four@ones{%
\begingroup
\xx@prepare@ones{0.3}%
\setbox\z@\hb@xt@1.16\wd\tw@{1\hss1\hss}%
\kern-.16\wd\tw@\vbox{\copy\z@\kern\z@\copy\z@}%
\endgroup}
%% \xx@prepare@ones{<ratio>}
\def\xx@prepare@ones#1{%
\setbox\tw@\hbox{1}%
\xx@adjust@font
\@tempdima\f@size\p@ \@tempdima.4\@tempdima
\fontsize{\@tempdima}{0}\selectfont}
%--------------------------------------- font size hack
%% constants
\def\xx@@cmtt{cmtt}
%% font family 'tczovtt'
% It's the same as 'cmtt' redefined in type1cm.
\DeclareFontFamily{OT1}{tczovtt}{\hyphenchar\font\m@ne}
\DeclareFontShape{OT1}{tczovtt}{m}{n}{%
<-9>cmtt8<9-10>cmtt9<10-12>cmtt10<12->cmtt12}{}
\DeclareFontShape{OT1}{tczovtt}{m}{it}{<->cmitt10}{}
\DeclareFontShape{OT1}{tczovtt}{m}{sl}{<->cmsltt10}{}
\DeclareFontShape{OT1}{tczovtt}{m}{sc}{<->sub*tczovtt/m/n}{}
\DeclareFontShape{OT1}{tczovtt}{m}{ui}{<->sub*tczovtt/m/n}{}
\DeclareFontShape{OT1}{tczovtt}{bx}{n}{<->sub*tczovtt/m/n}{}
\DeclareFontShape{OT1}{tczovtt}{bx}{it}{<->sub*tczovtt/m/it}{}
\DeclareFontShape{OT1}{tczovtt}{bx}{ui}{<->sub*tczovtt/m/n}{}
%% \xx@adjust@font
\def\xx@adjust@font{%
\ifx\f@family\xx@@cmtt
\fontfamily{tczovtt}\selectfont
\fi}
%--------------------------------------- done
\endinput
%% EOF
% upLaTeX文書
\documentclass[uplatex,a4paper]{jsarticle}
% 画期的新記法
\usepackage{tc1verbatim}
% 1TeXロゴ(\OneTeX)
\usepackage{bxtexlogo}
\bxtexlogoImport{*,OneTeX}
\begin{document}
\section{はじめての\OneTeX}
例えば、「Hello, {\TeX} world!」と出力する文書ソースは
次のようになる。
出力すべき文字の種類がどんなに多くても、
{\OneTeX}では入力は“1”だけで済んでしまう。
\oneverbatiminput{hello.1tex}
\end{document}
% upLaTeX文書
\documentclass[uplatex,a4paper]{jsarticle}
\usepackage{type1cm}% CMフォントの場合必要
\usepackage{bxtexlogo}
\bxtexlogoimport{*,SuyahTeX,OneTeX}
% 画期的新記法
\usepackage{tc1verbatim}
\renewcommand{\theenumi}{\onetally{enumi}}
\begin{document}
著名な{\TeX}のフォーマットは以下のものがある。
\begin{enumerate}
\item \LaTeX
\item plain \TeX
\item \ConTeXt
\item Lollipop
\item \SuyahTeX \label{itm:suyah}
\item \OneTeX \label{itm:one}
\end{enumerate}
特に\ref{itm:suyah}と\ref{itm:one}は重要である。
\end{document}
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111
11111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment