[Tex/LaTex] How to manually install ctex on Linux

cjklanguagespackagespdftextexlive

I have downloaded this package, and unzipped it into ~/texmf/tex/latex/ctex, which is where I have successfully installed other packages.

The first time I ran pdflatex ctex.ins, I received the following error, despite the fact that ctxdocstrip is supposed to be generated.

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./ctex.ins
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 3 language(s) loaded.
! I can't find file `ctxdocstrip'.
l.30 \input ctxdocstrip 
                        %
(Press Enter to retry, or Control-D to exit)
Please type another input file name:     
! Emergency stop.
l.30 \input ctxdocstrip 
                        %

Next, I downloaded ctxdocstrip and put it into the directory and made another attempt.

This produces the following output and error.

Generating file(s) ./ctex.sty ./ctexsize.sty ./ctexheading.sty ./ctexart.cls ./
ctexbook.cls ./ctexrep.cls ./ctexbeamer.cls ./ctxdoc.cls ./ctexcap.sty ./ctexho
ok.sty ./ctexpatch.sty ./ctex-c5size.clo ./ctex-cs4size.clo ./ctex-article.def 
./ctex-book.def ./ctex-report.def ./ctex-beamer.def ./ctex-scheme-plain.def ./c
tex-scheme-plain-article.def ./ctex-scheme-plain-book.def ./ctex-scheme-plain-r
eport.def ./ctex-scheme-plain-beamer.def ./ctex-scheme-chinese.def ./ctex-schem
e-chinese-article.def ./ctex-scheme-chinese-book.def ./ctex-scheme-chinese-repo
rt.def ./ctex-scheme-chinese-beamer.def ./ctex-name-gbk.cfg ./ctex-name-utf8.cf
g ./ctex.cfg ./ctexopts.cfg ./ctex-engine-pdftex.def ./ctex-engine-xetex.def ./
ctex-engine-luatex.def ./ctex-engine-aptex.def ./ctex-engine-uptex.def ./c19rm.
fd ./c19sf.fd ./c19tt.fd ./c70rm.fd ./c70sf.fd ./c70tt.fd ./ctex-fontset-window
s.def ./ctex-fontset-windowsnew.def ./ctex-fontset-windowsold.def ./ctex-fontse
t-adobe.def ./ctex-fontset-fandol.def ./ctex-fontset-mac.def ./ctex-fontset-fou
nder.def ./ctex-fontset-ubuntu.def ./translator-theorem-dictionary-ChineseGBK.d
ict ./translator-theorem-dictionary-ChineseUTF8.dict ./ctexspa.def ./ctexmakesp
a.tex ./ctexspamacro.tex ./zhadobefonts.tex ./zhfandolfonts.tex ./zhfounderfont
s.tex ./zhubuntufonts.tex ./zhwindowsfonts.tex ./ctxdocstrip.tex ./README.md 

Processing file ctex.dtx (style,ctex) -> ctex.sty
                         (style,ctexsize) -> ctexsize.sty
                         (style,ctexheading) -> ctexheading.sty
                         (class,article) -> ctexart.cls
                         (class,book) -> ctexbook.cls
                         (class,report) -> ctexrep.cls
                         (class,beamer) -> ctexbeamer.cls
                         (ctxdoc) -> ctxdoc.cls
                         (ctexcap) -> ctexcap.sty
                         (ctexhook) -> ctexhook.sty
                         (ctexpatch) -> ctexpatch.sty
                         (c5size) -> ctex-c5size.clo
                         (cs4size) -> ctex-cs4size.clo
                         (heading,article) -> ctex-article.def
                         (heading,book) -> ctex-book.def
                         (heading,report) -> ctex-report.def
Runaway text?
\GetIdInfo\GetIdInfo\GetIdInfo\GetIdInfo\GetIdInfo\GetIdInfo\GetIdInf\ETC.
! TeX capacity exceeded, sorry [main memory size=5000000].
\ctxCMD ->\GetIdInf
                   o
l.200   }
         ^^M
!  ==> Fatal error occurred, no output PDF file produced!

How can I resolve this error and successfully build the ctex package?

Best Answer

ctex is part of TeX Live. Hence, there is no need to install it manually and every reason not to do so. Instead, you should install it as other packages in TeX Live are installed.

Since you are using Debian's TeX Live packages, this means you should install it using apt or your preferred front-end. Were you to be using upstream TeX Live, you would use tlmgr instead.

This is not to say that it cannot be done manually, but that you ought not do it manually unless you really have no better option.

This said, if you want to typeset Chinese, you should really consider using XeTeX or, possibly, LuaTeX as it can handle large fonts and unicode fluently. Unless you have some truly compelling reason to stick with pdfTeX, there is just no point in struggling with traditional constraints on fonts and encodings.

Indeed, ctex.dtx begins with

% !TeX program  = XeLaTeX

so you might try processing the .ins with XeTeX rather than pdfTeX, even if you need to use pdfTeX for your own document.

Related Question