pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.08k stars 104 forks source link

How can I enter Chinese in the pgf document, and then use "l3build doc -q -H" to compile successfully? #1332

Closed yiddu closed 1 month ago

yiddu commented 1 month ago

Version

3.1.10

Details

I hope to translate tikz documents into Chinese, but I directly use "3build doc -q -H" to compile when I input Chinese in the pgf tex file, even if I use the {ctex} macro package, or After using the \text{} command, is there a way to directly change the document content of pgf from English to Chinese and still ensure normal compilation?

muzimuzhi commented 1 month ago

As a proof-of-concept, this seems to work:

diff --git a/doc/generic/pgf/pgfmanual-en-introduction.tex b/doc/generic/pgf/pgfmanual-en-introduction.tex
index afe6c808..2008ca1d 100644
--- a/doc/generic/pgf/pgfmanual-en-introduction.tex
+++ b/doc/generic/pgf/pgfmanual-en-introduction.tex
@@ -8,9 +8,9 @@
 % See the file doc/generic/pgf/licenses/LICENSE for more details.

-\section{Introduction}
+\section{介绍}

-Welcome to the documentation of \tikzname\ and the underlying \pgfname\ system.
+欢迎来到 \tikzname\ 和底层 \pgfname\ 系统的文档。
 What began as a small \LaTeX\ style for creating the graphics in my (Till
 Tantau's) PhD thesis directly with pdf\LaTeX\ has now grown to become a
 full-blown graphics language with a manual of over a thousand pages. The wealth
diff --git a/doc/generic/pgf/pgfmanual-en-main-body.tex b/doc/generic/pgf/pgfmanual-en-main-body.tex
index cb3d6843..9937c009 100644
--- a/doc/generic/pgf/pgfmanual-en-main-body.tex
+++ b/doc/generic/pgf/pgfmanual-en-main-body.tex
@@ -222,8 +222,8 @@
 }

-\title{\bfseries The \tikzname\ and {\Large PGF} Packages\\
-  \large Manual for version \pgfversion\\[1mm]
+\title{\bfseries \tikzname\ 和 {\Large PGF} 宏包\\
+  \large 版本 \pgfversion{} 的文档\\[1mm]
 \large\href{https://github.com/pgf-tikz/pgf}{\texttt{https://github.com/pgf-tikz/pgf}}}
 \author{Till Tantau\footnote{Editor of this documentation. Parts of
     this documentation have been written by other authors as indicated
@@ -241,6 +241,7 @@

 \include{pgfmanual-en-introduction}

+\end{document} % for quick test

 \part{Tutorials and Guidelines}
diff --git a/doc/generic/pgf/pgfmanual-en-main-preamble.tex b/doc/generic/pgf/pgfmanual-en-main-preamble.tex
index b5f5b11b..6c5a9643 100644
--- a/doc/generic/pgf/pgfmanual-en-main-preamble.tex
+++ b/doc/generic/pgf/pgfmanual-en-main-preamble.tex
@@ -156,6 +156,7 @@
 \usepackage{pifont}

 \ifluatex
+  \usepackage{ctex}
 %  \usepackage[no-math]{fontspec}
 %  \usepackage{luatextra}

image image

l3build doc executes lualatex since the graphdrawing library (documented in Part IV, "Graph Drawing") needs LuaTeX. https://github.com/pgf-tikz/pgf/blob/12f17834c849a659b8829bbc9122bc459f585917/build.lua#L19

yiddu commented 1 month ago

I tried to change only one sentence to Chinese like you did, but compiling the whole manual in its entirety still prompted an error and could not complete the compilation properly. "Output written on pgfmanual.pdf (1299 pages, 8882901 bytes). Transcript written on pgfmanual.log. ! Compilation failed",here is my compilation log pgfmanual.log

muzimuzhi commented 1 month ago

From the attached log, none of ctex.sty, luatexja.sty, and fontspec.sty were loaded. Then it's no surprise that the "Missing character" errors occur:

Missing character: There is no 现 (U+73B0) in font [lmroman10-regular]:+tlig;!
.
<argument> ...not:N \tex_shipout:D \box_use:N \l_shipout_box 
                                                  \__shipout_drop_firstpage_...
l.115 

I pushed the diff shown in https://github.com/pgf-tikz/pgf/issues/1332#issuecomment-2109910570 to branch gh1332-doc-cn. You can do translations based on it, or share your modifications if you'd like to know "why my changes didn't work".

yiddu commented 1 month ago

Thank you very much for your support, the problem was successfully solved. But after I added the relevant content exactly as you did, strange problems still occurred. By commenting one by one, I found that part Utilities seemed to cause the problem. After I commented it out, the problem no longer occurred, but I later restored it. , the problem cannot be reproduced. But very fortunately, the problem no longer exists!