Skip to content

Instantly share code, notes, and snippets.

View dohyunkim's full-sized avatar

Dohyun Kim dohyunkim

View GitHub Profile
@dohyunkim
dohyunkim / fontcharglyph.tex
Created September 9, 2015 12:17
view all chars from current font (lualatex only)
\documentclass[a4paper]{article}
\usepackage{fontspec, luacode, xcolor}
%\setmainfont{HCR Batang LVT}[Script=Hangul, Language=Korean]
\setmainfont{Linux Libertine O}
%\setmainfont{TeX Gyre Pagella}
%\setmainfont{Source Han Sans K}[Script=Hangul, Language=Korean]
%\setmainfont{NanumMyeongjoOTF YetHangul}[Script=Hangul, Language=Korean]
%\setmainfont{NanumBarunGothicOTF YetHangul}[Script=Hangul, Language=Korean]
\pagestyle{myheadings} \markright{\footnotesize\fontname\font}
\def\tickblue{{\color{blue}\vrule width1pt height.05pt depth.05pt}}
--
-- This is file `luamplib.lua',
-- generated with the docstrip utility.
--
-- The original source files were:
--
-- luamplib.dtx (with options: `lua')
--
-- See source file 'luamplib.dtx' for licencing and contact information.
--
@dohyunkim
dohyunkim / readcsv.lua
Last active January 8, 2016 13:37
read csv and print latex tabular
readcsv = readcsv or {}
local readcsv = readcsv
local function readcsvlines (s, sep)
sep = sep or ','
s = s .. "\n"
s = s:gsub("[\r\n]+", "\n") -- unix newline
local curr, t = 1, {{}}
while true do
local tt, i, a, c = t[#t], curr
@dohyunkim
dohyunkim / dofirst.tex
Created February 27, 2016 11:12
단어의 첫 글자만 다르게
% see http://www.ktug.org/xe/index.php?document_srl=214192
\def\dofirst#1{\dodofirst#1 \stopdofirst{} }
\def\dodofirst#1 {%
\ifx\stopdofirst#1%
\unskip
\else
\in@{,#1,}{,a,am,an,of,for,in,on,the,to,with,}%
\ifin@
\else
\expandafter\DoFirst
@dohyunkim
dohyunkim / ucharclass.tex
Last active May 10, 2016 04:17
it's not easy to use ucharclasses package with polyglossia korean.
%!TEX program = xelatex
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{korean}
\newfontfamily\koreanfont{NanumMyeongjo}[Ligatures=TeX]
\usepackage{ucharclasses}
\setTransitionsForCJK{\begingroup\koreanfont
\XeTeXlinebreaklocale"ko"
\XeTeXlinebreakpenalty=50
@dohyunkim
dohyunkim / subst.tex
Created June 14, 2016 11:45
tex macro, gsub
\documentclass{article}
\makeatletter
\def\gsub#1#2#3{%
\in@{#2}{#3}\ifin@
\errhelp{`#3' contains `#2', which is not allowed.}%
\errmessage{Nested Substitution}%
\fi
\in@{#2}{#1}\ifin@
\def\gsubresult##1#2##2\par{##1#3##2}%
\def\next{\expandafter\gsub\expandafter{\gsubresult#1\par}{#2}{#3}}%
@dohyunkim
dohyunkim / xenanumtype1.tex
Created June 29, 2016 09:26
xelatex + nanum type1
\newXeTeXintercharclass \XeTeXcharclassID
\let \XeTeXcharclassOP \XeTeXcharclassID
\let \XeTeXcharclassCL \XeTeXcharclassID
\input load-unicode-xetex-classes\relax
\XeTeXcharclass "B7 = \XeTeXcharclassID
\count@="AC00 \loop
\XeTeXcharclass\count@ = \XeTeXcharclassID
\ifnum\count@<"D7A3 \advance\count@\@ne
\repeat
\XeTeXinterchartoks 0 \XeTeXcharclassID = {\LAID}
@dohyunkim
dohyunkim / nanum-uni-vf.lua
Last active July 15, 2016 01:53
nanum unicode virtual font for luatex
local T1toUni = {
-- removed [0] = 0x0060,
-- changed 0x27 from 0x2019
-- changed 0x60 from 0x2018
-- changed 0x18 nil to 0x2030
0x00B4, 0x02C6, 0x02DC, 0x00A8, 0x02DD, 0x02DA, 0x02C7,
0x02D8, 0x00AF, 0x02D9, 0x00B8, 0x02DB, 0x201A, 0x2039, 0x203A,
0x201C, 0x201D, 0x201E, 0x00AB, 0x00BB, 0x2013, 0x2014, 0x200B,
0x2030, 0x0131, 0x0237, 0xFB00, 0xFB01, 0xFB02, 0xFB03, 0xFB04,
0x2423, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
@dohyunkim
dohyunkim / trans.tex
Created February 14, 2017 07:23
color transparency test
\input luaotfload.sty
\input luamplib.sty
\font\redtr="[lmroman12-bold.otf]:color=ff00007F" at 40pt
\font\bluetr="[lmroman12-bold.otf]:color=0000ff7f" at 40pt
\leavevmode\hbox{\redtr A\kern-0.5em \bluetr B}
\mplibsetformat{metafun}
\mplibcode
beginfig(0);
path p; p:= unitcircle scaled 2cm;
@dohyunkim
dohyunkim / address.csv
Last active March 2, 2017 12:09
Formtec 주소용 라벨 LQ3212 (100 x 45mm). 페이지당 12개 라벨 총 240 라벨.
성명 주소 우편번호 전화번호 부수 비고 ...
성명 쉼표가, 들어간, 주소 우편번호 전화번호 부수 비고 ...
(전체 16줄)