This page looks best with JavaScript enabled
清世何須憂廟廊——漢語詩詞 LaTeX 樣式
👨李梅亭 · · · 🔢 616 words· ⏲️ 2 min read ·🏄 ... visitors ·👀 ... views

Typing some Chinese classical poems, I found most of the early examples are created for layouting English poems. Below I give a layout example of Tang poems anthology. Rather than a general solution, it’s just a particular example. Pls put below packages into the preamble of your document.

1
2
3
4
%漢字自動注音
\usepackage{xpinyin}
%漢字注音設置
\xpinyinsetup{ratio = .4,font =\ubufont,multiple={\color{black}}}

Tang Poem Environment

The Output:

1
2
3
4
5
6
7
8
9
\section{薛正明}
\begin{poemz}{薛正明}{遊鴈蕩}
	東風驛路馬蹄香,曉起行春到夕陽。\\
	三月鶯啼花柳寺,幾家人住水雲鄉。\\
	名山不用問樵字,清世何須憂廟廊。\\
	且脫綸巾隨洞客,紫簫吹月夜天涼。
\end{poemz}
此詩本事又可參見\lref{王績《野望》}。另,\textsf{曹丕}\emph{典論\bn 論文}「不假良史之辭,不托飛馳之勢,而聲名自傳於後。」\pref{虞世南《蟬》}

Detailed Design Process

Step 1: Define New Poem Environment

Define New Poem Environment with tcolorbox and xpinyin Packages

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
\newenvironment{poem}[3] %code={\doublespacing},
{\begin{tcolorbox}[left=1mm,right=1mm,top=3mm,bottom=2mm,enhanced,breakable,pad at break*=.5mm,title=#2,
		colframe=blue!50!black,colback=blue!10!white,colbacktitle=blue!5!myred!10!white,
		fonttitle=\Large\HGBM,coltitle=black,attach boxed title to top center=
		{yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},
		boxed title style={boxrule=0.5mm,
			frame code={ \path[tcb fill frame] ([xshift=-4mm]frame.west)
				-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)
				-- (frame.south east) -- (frame.south west) -- cycle; },
			interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west)
				-- (interior.north west) -- (interior.north east)
				-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west)
				-- cycle;} }]
      \index[ian]{#1!#2}\index[ibn]{#2[#1]}\begin{pinyinscope} \begin{center}\subsectionmark{#2}\phantomsection
      \addcontentsline{toc}{subsection}{#2}\label{#1《#2》}\hypertarget{#1《#2》}
      \LARGE\linespread{1.4}\selectfont #3  %\HGBUM\ZSKS
	}
{\end{center}\end{pinyinscope}\end{tcolorbox}}

Step 2: Define New Cross Referencing Command

1
2
3
4
5
6
%邊註交互引用
\NewDocumentCommand\pref{m}
{\marginpar{\ding{43}\HGB\ubufontc\hyperlink{#1}#1(\pageref{#1})}}
%正文交互引用
\NewDocumentCommand\lref{m}
{{\HGB\ubufontc\hyperlink{#1}#1(\pageref{#1})}}

This will output:

Step 3: Creat Author or Title Index, etc

As shown in my another article Zhmakeindex and the Indices Creating of Chinese Books, the codes and the outputs will be:

1
2
3
4
5
6
%人名地名書名索引
\printindex[isn] % zhmakeindex -s isn.ist isn.idx
%作者索引
\printindex[ian] % zhmakeindex -s ian.ist ian.idx 
%篇目索引
\printindex[ibn] % zhmakeindex -s ibn.ist ibn.idx

The article was recently updated on Monday, October 23, 2023, 13:40:11 by 👩 高松年.


李梅亭
支持作者

🤑乞討碼🤑