Skip to content

Instantly share code, notes, and snippets.

View dohyunkim's full-sized avatar

Dohyun Kim dohyunkim

View GitHub Profile
@dohyunkim
dohyunkim / legalhanjanum.sty
Last active August 29, 2015 14:03
한자 갖은자로 숫자를 표시한다.
\edef\legalhanjanumATcatcode{\catcode`@=\the\catcode`@\relax}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax\else
\ProvidesPackage{legalhanjanum}[2014/06/27 v0.1 number to hanja number]
\fi
\catcode`@=11
\protected\def\legalhanjanum#1{%
\begingroup\edef\x{#1}\count@\z@\toks@{}\expandafter\hanjanum@\x\@@\endgroup
}
\def\hanjanum@#1{% 토큰 순서 뒤집기
@dohyunkim
dohyunkim / xxruby.sty
Created June 28, 2014 04:03
xxruby, a variant of ruby command for Korean document
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax\else
\ProvidesPackage{xxruby}[2014/05/20 v0.1 consecutive ruby annotations]
\fi
\ifdefined\directlua\else
\ifdefined\ruby\else
\usepackage{ruby}
\def\rubysep{-1.25ex}
\def\rubysize{0.6}
@dohyunkim
dohyunkim / webgraphics.lua
Last active August 29, 2015 14:03
include web graphics
local err,warn,info,log = luatexbase.provides_module({
name = 'webgraphics',
date = '2014/06/30',
version = 0.1,
description = 'include graphics on the web',
author = 'Dohyun Kim',
license = 'public domain',
})
webgraphics = webgraphics or {}
@dohyunkim
dohyunkim / bneedle.tex
Last active August 29, 2015 14:16
buffon's needle with luamplib
\input luamplib.sty
\mplibnumbersystem{double}
\mplibtextextlabel{enable}
\ifdefined\n\else \def\n{5000}\fi
\ifdefined\length\else \def\length{100}\fi
\ifdefined\distance\else \def\distance{100}\fi
\ifnum\length>\distance \let\length\distance\fi
\mplibcode
total := \n; l := \length; d := \distance;
path needle, hline;
@dohyunkim
dohyunkim / pispiral.tex
Last active August 29, 2015 14:17
Two versions of Pi spiral. In the latter, Pi is calculated by MetaPost thanks to its `decimal` number system
\documentclass[margin=4pt]{standalone}
\usepackage{fontspec}
\setmainfont{Helvetica}
\usepackage{luamplib}
\mplibnumbersystem{double}
\mplibtextextlabel{enable}
\edef\pidecimal{\directlua{
local pidec = [[
14159 26535 89793 23846 26433 83279 50288 41971 69399 37510
58209 74944 59230 78164 06286 20899 86280 34825 34211 70679
@dohyunkim
dohyunkim / colorVerb.lua
Last active August 29, 2015 14:22
colorize verbatims
luatexbase.provides_module({
name = 'colorVerb',
date = '2011/01/20',
version = 0.1,
description = 'Colorize Commands/Braces/Brackets in Verbatim',
author = 'Dohyun Kim',
license = 'Public Domain',
})
colorVerb = colorVerb or {}
@dohyunkim
dohyunkim / drawcharbox.lua
Last active November 15, 2018 03:37
draw box around glyphs
luatexbase.provides_module(
{
name = 'drawcharbox',
date = '2011/05/20',
version = 0.2,
description = 'draw char box for each char',
author = 'Dohyun Kim',
license = 'Public Domain',
})
@dohyunkim
dohyunkim / r.pl
Last active August 29, 2015 14:22
romanization of hangul pronunciation -- 제1차 라텍 스터디 과제
#!/usr/bin/env perl
my @LC = map {$_ eq "-" ? "" : $_} qw(
g kk n d tt r m b pp s ss - j jj ch k t p h
);
my @MV = qw(
a ae ya yae eo e yeo ye o wa wae oe yo u wo we wi yu eu ui i
);
my @TC = map {$_ eq "-" ? "" : $_} qw(
- G kk ks n nj nh D R lG lm lB ls lt lp lh m B ps s ss ng j ch k t p h
@dohyunkim
dohyunkim / fontglyphs.sty
Last active September 7, 2015 10:56
draw glyph box for each and every glyph in a truetype/opentype font
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname selectfont\endcsname\relax
\edef\catcodeofatchar{\catcode`@=\the\catcode`@}
\catcode`@=11
\newdimen\@tempdima \newdimen\@tempdimb
\newcount\@tempcnta \newcount\@tempcntb
\else
\ProvidesPackage{fontglyphs}[2015/06/15 v0.1 Draw box of each and every glyphs in a truetype/opentype font]
\fi
@dohyunkim
dohyunkim / mpcalc.tex
Last active August 29, 2015 14:23
MetaPost as a math calculator
\input luamplib.sty
\def\mpcalc#1#2#3{% #1 control sequence
% #2 math formular
% #3 precision ( <= 1000 )
\begingroup
\setbox0\hbox{%
\mplibnumbersystem{decimal}%
\mplibcode
numberprecision := #3;