Skip to content

Instantly share code, notes, and snippets.

@watamario15
Last active April 21, 2023 15:53
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 watamario15/66eba9e9cfbb008c86e833352729f800 to your computer and use it in GitHub Desktop.
Save watamario15/66eba9e9cfbb008c86e833352729f800 to your computer and use it in GitHub Desktop.
Japanese LaTeX templates
\RequirePackage{plautopatch}
\plautopatchdisable{eso-pic}
\documentclass[autodetect-engine, jis2004, dvipdfmx, a4j, titlepage]{jsarticle}
\usepackage[top=25.4truemm, bottom=25.4truemm, left=19truemm, right=19truemm]{geometry}
\usepackage{ascmac, enumitem, graphicx, here, mathtools, newtxmath, newtxtext, listings, seqsplit, spverbatim, xcolor, multicol}
\usepackage[hidelinks, colorlinks, linkcolor=black, citecolor=black, urlcolor=blue, pdfusetitle]{hyperref}
\usepackage[T1]{fontenc}
\usepackage[deluxe]{otf}
\usepackage[noalphabet, unicode]{pxchfon} % フォント変更。必ず otf の後。
\setminchofont[0]{BIZ-UDMinchoM.TTC} % Windows 10 and later
\setboldminchofont[0]{BIZ-UDGothicB.TTC} % Windows 10 and later
\setgothicfont[0]{BIZ-UDGothicR.TTC} % Windows 10 and later
\setboldgothicfont[0]{BIZ-UDGothicB.TTC} % Windows 10 and later
% \setminchofont{BIZUDMincho-Regular.ttf} % Manual installation
% \setboldminchofont{BIZUDGothic-Bold.ttf} % Manual installation
% \setgothicfont{BIZUDGothic-Regular.ttf} % Manual installation
% \setboldgothicfont{BIZUDGothic-Bold.ttf} % Manual installation
\renewcommand{\headfont}{\sffamily\bfseries}
\mathtoolsset{showonlyrefs}
\definecolor{comment}{RGB}{0, 128, 0}
\definecolor{string}{RGB}{163, 21, 21}
\definecolor{keyword}{RGB}{0, 0, 255}
\lstdefinelanguage{SML}{
morekeywords= {
EQUAL, GREATER, LESS, NONE, SOME, abstraction, abstype, and, andalso, array, as, before, bool, case, char, datatype, do, else, end, eqtype, exception, exn, false, fn, fun, functor, handle, if, in, include, infix, infixr, int, let, list, local, nil, nonfix, not, o, of, op, open, option, orelse, overload, print, raise, real, rec, ref, sharing, sig, signature, string, struct, structure, substring, then, true, type, unit, val, vector, where, while, with, withtype, word
},
morestring=[b]",
morecomment=[s]{(*}{*)}
}
\lstdefinelanguage{CASL2}{
morekeywords={
START, END, DS, DC, OUT, RPUSH, RPOP, LD, ST, LAD, ADDA, SUBA, SUBL, AND, OR, XOR, CPA, CPL, SLA, SRA, SLL, SRL, JPL, JMI, JNZ, JZE, JOV, JUMP, PUSH, POP, CALL, RET, SVC, NOP, GR0, GR1, GR2, GR3, GR4, GR5, GR6, GR7
},
morecomment=[l]{;},
morestring=[b]'
}
\lstdefinelanguage[postgres]{SQL}{
morekeywords={with, is},
alsoletter={.}
}
\lstset{
language={C},
basicstyle={\footnotesize\ttfamily},
commentstyle={\footnotesize\color{comment}},
stringstyle=\footnotesize\color{string},
identifierstyle={\footnotesize},
numberstyle={\scriptsize},
keywordstyle={\footnotesize\color{keyword}},
frame={tb},
breaklines=true,
columns=[l]{fullflexible},
xrightmargin=0zw,
xleftmargin=3zw,
lineskip=-0.5ex,
numbers=left,
numbersep=1zw,
stepnumber=1,
keepspaces=true,
showstringspaces=false
}
\title{\sffamily\bfseries}
\author{}
\date{提出年月日: \today}
\begin{document}
\maketitle
\end{document}
\documentclass[a4j, titlepage]{ltjsarticle}
\usepackage[top=25.4truemm, bottom=25.4truemm, left=19truemm, right=19truemm]{geometry}
\usepackage{ascmac, enumitem, graphicx, here, mathtools, newtxmath, newtxtext, listings, seqsplit, spverbatim, xcolor, multicol}
\usepackage[unicode, hidelinks, colorlinks, linkcolor=blue, citecolor=blue, urlcolor=blue, pdfusetitle]{hyperref}
\usepackage[match]{luatexja-fontspec}
\setmainjfont[BoldFont=BIZ UDPGothic Bold, YokoFeatures={JFM=prop}]{BIZ UDPMincho}
\setsansjfont[YokoFeatures={JFM=prop}]{BIZ UDPGothic}
\setmonojfont{BIZ UDGothic}
\IfFontExistsTF{BIZ-UDGothicR.ttc} {
\setmonofont[Extension=.ttc, FontIndex=0, UprightFont=*R, BoldFont=*B, CharacterWidth=Half]{BIZ-UDGothic}
} {
\setmonofont[Extension=.ttf, UprightFont=*-Regular, BoldFont=*-Bold, CharacterWidth=Half]{BIZUDGothic}
}
\renewcommand{\headfont}{\sffamily\bfseries}
\mathtoolsset{showonlyrefs}
\definecolor{comment}{RGB}{0, 128, 0}
\definecolor{string}{RGB}{163, 21, 21}
\definecolor{keyword}{RGB}{0, 0, 255}
\lstdefinelanguage{SML}{
morekeywords= {
EQUAL, GREATER, LESS, NONE, SOME, abstraction, abstype, and, andalso, array, as, before, bool, case, char, datatype, do, else, end, eqtype, exception, exn, false, fn, fun, functor, handle, if, in, include, infix, infixr, int, let, list, local, nil, nonfix, not, o, of, op, open, option, orelse, overload, print, raise, real, rec, ref, sharing, sig, signature, string, struct, structure, substring, then, true, type, unit, val, vector, where, while, with, withtype, word
},
morestring=[b]",
morecomment=[s]{(*}{*)}
}
\lstdefinelanguage{CASL2}{
morekeywords={
START, END, DS, DC, OUT, RPUSH, RPOP, LD, ST, LAD, ADDA, SUBA, SUBL, AND, OR, XOR, CPA, CPL, SLA, SRA, SLL, SRL, JPL, JMI, JNZ, JZE, JOV, JUMP, PUSH, POP, CALL, RET, SVC, NOP, GR0, GR1, GR2, GR3, GR4, GR5, GR6, GR7
},
morecomment=[l]{;},
morestring=[b]'
}
\lstdefinelanguage[postgres]{SQL}{
morekeywords={with, is},
alsoletter={.}
}
\lstset{
language={C},
basicstyle={\footnotesize\ttfamily},
commentstyle={\footnotesize\color{comment}},
stringstyle=\footnotesize\color{string},
identifierstyle={\footnotesize},
numberstyle={\scriptsize},
keywordstyle={\footnotesize\color{keyword}},
frame={tb},
breaklines=true,
columns=[l]{fullflexible},
xrightmargin=0\zw,
xleftmargin=3\zw,
lineskip=-0.5ex,
numbers=left,
numbersep=1\zw,
stepnumber=1,
keepspaces=true,
showstringspaces=false
}
\title{\sffamily\bfseries}
\author{}
\date{提出年月日: \today}
\begin{document}
\maketitle
\end{document}

Requirements

Might be insufficient.

The (u)pLaTeX version and LuaTeX-ja version isn't the same, as LuaTeX-ja is more powerful than (u)pLaTeX. The (u)pLaTeX version is less tested than the LuaTeX-ja version.

(u)pLaTeX

tlmgr install plautopatch, ascmac, enumitem, graphicx, here, mathtools, newtx, listings, seqsplit, spverbatim, xcolor, hyperref, fontenc, otf, pxchfon, xstring, realscripts, txfonts

Fonts: BIZ UDGothic, BIZ UDMincho

Manual installation: plistings

Seems like plistings and jlisting doesn't work on TeXLive 2023? Wow (u)pLaTeX is finally collapsing!

LuaTeX-ja

tlmgr install ascmac, enumitem, graphicx, here, mathtools, newtx, listings, luatexja-fontspec, seqsplit, spverbatim, xcolor, hyperref, xstring, realscripts, txfonts

Fonts: BIZ UDPGothic, BIZ UDPMincho, BIZ UDGothic

Japanese test string

pLaTeX

森\UTF{9DD7}外と内田百\UTF{9592}とが\UTF{9AD9}島屋に行くところを、\CID{7652}飾区の\CID{13706}野家で想像したら\CID{13803}られた。

upLaTeX / LuaTeX

森鷗外と内田百閒とが髙島屋に行くところを、葛飾区の𠮷野家で想像したら𠮟られた。

When (u)pLaTeX complains that fonts are missing despite you've already installed them

  1. Locate texmf.cnf files by invoking kpsewhich -a -format=cnf texmf.cnf
  2. See which file has OSFONTDIR variable
  3. Modify it to point to the font directory of your system, which contains the required fonts
  4. Run mktexlsr (you may need sudo if you installed TeXLive system-wide)
  5. Try typesetting your document again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment