diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /info/ctex-faq/src/ctex-faq.sty |
Initial commit
Diffstat (limited to 'info/ctex-faq/src/ctex-faq.sty')
-rw-r--r-- | info/ctex-faq/src/ctex-faq.sty | 503 |
1 files changed, 503 insertions, 0 deletions
diff --git a/info/ctex-faq/src/ctex-faq.sty b/info/ctex-faq/src/ctex-faq.sty new file mode 100644 index 0000000000..204bececfa --- /dev/null +++ b/info/ctex-faq/src/ctex-faq.sty @@ -0,0 +1,503 @@ +%% This is a LaTeX2e package for the CTeX FAQ document. +%% +%% Created by aloft (aloft@ctex.org) +%% +%% Version 0.8 (24-May-2009) +%% +%% $Id: ctex-faq.sty 83 2007-01-30 09:48:43Z aloft $ +%% +\def\filedate{2009/05/24} +\def\fileversion{0.8} +\NeedsTeXFormat{LaTeX2e}[1994/06/01] +\ProvidesPackage{ctex-faq}[\filedate\space\fileversion\space(Chinese TeX FAQ macros)] +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Options +% +\newif\ifnewfaqmark +\newfaqmarktrue +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Loading packages +% +% +\RequirePackage{ifpdf} +\RequirePackage[UTF8,fancyhdr]{ctex} +\ifpdf + \RequirePackage[pdftex,% + unicode,% + bookmarksnumbered,% + colorlinks,% + linkcolor=blue,% + hyperindex,% + plainpages=false,% + pdfstartview=FitH]{hyperref} +\else + \RequirePackage[dvipdfm,% + unicode,% + bookmarksnumbered,% + colorlinks,% + linkcolor=blue,% + hyperindex,% + plainpages=false,% + pdfstartview=FitH]{hyperref} +\fi +% +% +\RequirePackage{color,verbatim,cite} +\RequirePackage{texnames,makeidx,indentfirst} +\RequirePackage{amsmath,amssymb,amsfonts,bm,manfnt} +\RequirePackage{textcomp} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Typesetting TeX names +% +% +\DeclareRobustCommand\CTeX{$\mathbb{C}$\kern-.05em\TeX} +\DeclareRobustCommand\MiKTeX{MiK\TeX} +\DeclareRobustCommand\fpTeX{fp\TeX} +\DeclareRobustCommand\teTeX{te\TeX} +\DeclareRobustCommand\ConTeXt{Con\TeX{}t} +\DeclareRobustCommand\TeXLive{\TeX{}Live} +% +\newcommand\PS{PostScript} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Modifing Styles +% +% +\setlength{\parskip}{0.75ex plus .2ex minus .5ex} +\renewcommand{\baselinestretch}{1.2} +% +% we don't want headings +\pagestyle{plain} +% +% we `number' our sections alphabetically +\renewcommand{\thesection}{\Alph{section}} +% +% we use superscript numerical citation with brackets +\def\@cite#1{\textsuperscript{[#1]}} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Redefine some commands and environments +% +% +\newcommand*\contrib[2][]{{\it #2}\hspace*{1ex}% + \def\reserved@a{#1}% + \ifx\reserved@a\@empty + (no email) + \else + (\href{mailto:#1}{#1}) + \fi} +% +% Quoted URL +\newcommand\faqurl[1]{\begin{quote}\url{#1}\end{quote}} +% +% Make index entry +\newcommand\faqindex[1]{\index{#1}#1} +% +% Quoted verbatim environment +\@namedef{prompt}{\quote\verbatim} +\expandafter\def\csname endprompt\endcsname {\endverbatim\endquote} +% +% +\newenvironment{lined}[1]% + {\begin{center}\begin{minipage}{#1}\hrule\medskip} + {\vspace{-1ex}\hrule \end{minipage}\end{center}} +% +% Marginal notes +\newcommand{\MarginalNotes}[1]{% + \hskip 1sp \marginpar{\small\sffamily\raggedright #1}} +% +% Set RCS Keywords +\def\RCS{\RCS@process} +\def\RCS@process$#1: #2 ${% + \def\RCS@keyword{#1}% + \def\RCS@value{#2}% + \ifx\RCS@value\empty% + \def\RCS@value{N/A}% + \fi% + \@ifundefined{RCS@handle\RCS@keyword}% + {\expandafter\edef\csname RCS\RCS@keyword\endcsname{\RCS@value}}% + {\csname RCS@handle\RCS@keyword\endcsname}} +\def\RCS@handleDate{% + \ifx\RCS@value{N/A}% + \def\RCSDate\today% + \let\RCSTime\relax% + \else% + \expandafter\RCS@setDate\RCS@value\@nil% + \fi} +\def\RCS@setDate#1-#2-#3 #4\@nil{% + \def\RCSday{#3}% + \def\RCSmonth{#2}% + \def\RCSyear{#1}% + \def\RCSDate{\begingroup% + \day \number\RCSday% + \month \number\RCSmonth% + \year \number\RCSyear% + \today\endgroup} + \def\RCSTime{#4}} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Typesetting Commands +% +% +\newenvironment{latexcmd}% + {\list{}{}\item\relax% + \begin{tabular}{|l|}\hline\rule{0pt}{1em}\ignorespaces\small}% + {\\\hline\end{tabular}\endlist} +% +% +% Index entry for an command +\newcommand\bs{\texorpdfstring{\texttt{\symbol{92}}}{\textbackslash}} %Print backslash +\def\cmdname{Commands} +\newcommand\cmdindex[1]{% + \index{\cmdname!#1@\texttt{\bs#1}}% + \index{#1@\texttt{\hspace*{-1.2ex}\bs #1}}} +\newcommand\cmd[1]{\cmdindex{#1}\texttt{\bs#1}} %Print command +\newcommand\cs[1]{\texttt{\bs#1}} %Print command without index +% +% Index entry for an package +\def\pkgname{Packages} +\newcommand\pkgindex[1]{% + \index{\pkgname!#1@\textsf{#1}}% + \index{#1@\textsf{#1}}} +\newcommand\pkg[1]{\pkgindex{#1}\textsf{#1}} %Print package +% +% Index entry for an environment +\def\envname{Environments} +\newcommand\envindex[1]{% + \index{\envname!#1@\texttt{#1}}% + \index{#1@\texttt{#1}}} +\newcommand\env[1]{\envindex{#1}\texttt{#1}} +% +% Argument and optional argument +\def\parg#1{\mbox{$\langle${\it #1\/}$\rangle$}} +\def\@smarg#1{{\tt\string{}\parg{#1}{\tt\string}}} +\def\@marg#1{{\tt\string{}{\rm #1}{\tt\string}}} +\def\marg{\@ifstar\@smarg\@marg} +\def\@soarg#1{{\tt[}\parg{#1}{\tt]}} +\def\@oarg#1{{\tt[}{\rm #1}{\tt]}} +\def\oarg{\@ifstar\@soarg\@oarg} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Typesetting Code Fragments +% +% +%% using listings.sty +%%\lstset{language=[LaTeX]TeX} +%%\lstset{framexleftmargin=5pt, frame=shadowbox, rulesepcolor=\color{blue}} +%%\lstset{xleftmargin=20pt, xrightmargin=20pt} +%%\lstset{breaklines=false} +%%\lstnewenvironment{code}[2][] +%% {\lst@TestEOLChar{#2}% +%% \lstset{#1}% +%% \csname\@lst @SetFirstNumber\endcsname} +%% {\csname\@lst @SaveFirstNumber\endcsname} +%% +%% using verbatim.sty +%%\@namedef{code}{\quote\begingroup\@verbatim\frenchspacing\@vobeyspaces\verbatim@start} +%%\expandafter\def\csname endcode\endcsname {\endverbatim\endquote} +% +% +% This part is hacked from the verbatim.sty and lshort.sty +% +\definecolor{example@bkcolor}{gray}{.875} +% +\newwrite\example@out +\def\example@start{% + \begingroup% Lets Keep the Changes Local + \@bsphack + \immediate\openout \example@out \jobname.exa + \let\do\@makeother\dospecials\catcode`\^^M\active + \def\verbatim@processline{% + \immediate\write\example@out{\the\verbatim@line}}% + \verbatim@start} +\def\example@finish{\immediate\closeout\example@out\@esphack\endgroup} +\def\example@code#1#2{% + \colorbox{#1}{% + \begin{minipage}[c]{#2}% + \small\verbatiminput{\jobname.exa}% + \end{minipage}% + }% +} +\def\example@output#1{% + \let\savefboxrule\fboxrule% + \let\savefboxsep\fboxsep% + \setlength{\fboxrule}{0.1pt}% + \setlength{\fboxsep}{3mm}% + \fbox{% + \begin{minipage}[c]{#1}% + \setlength{\fboxrule}{\savefboxrule}% + \setlength{\fboxsep}{\savefboxsep}% + \setlength{\parskip}{1ex plus 0.4ex minus 0.2ex}% + \begin{trivlist}\item\small\input{\jobname.exa}\end{trivlist} + \end{minipage} + }% +} +% +% This is two environments to set LaTeX examples. +% +% example: On the left side the source text and on the +% right side the typeset text. +% +\newenvironment{example}% + {\example@start}% + {\example@finish% + \list{}{\itemindent-\leftmargin}\item\relax% + \makebox[\textwidth][c]{% + \example@code{example@bkcolor}{0.5\textwidth}% + \hspace{10pt}% + \example@output{0.4\textwidth}% + }% + \endlist} +% +% code: Only the source text +% +\newenvironment{code}% + {\example@start}% + {\example@finish% + \list{}{\itemindent-\leftmargin}\item\relax% + \makebox[\textwidth][c]{% + \example@code{example@bkcolor}{0.96\textwidth}% + }% + \endlist} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Dangerous and doubly dangerous bends +% +% +\newlength{\dbend@width} +\newlength{\ddbend@width} +\newlength{\dbend@voffset} +\def\setdbend@width{% + \settowidth{\dbend@width}{\dbend}% + \setlength{\ddbend@width}{\dbend@width}% + \multiply\dbend@width by 2% + \multiply\ddbend@width by 3% + \advance\ddbend@width by 1pt% + \settoheight{\dbend@voffset}{\dbend}% + \multiply\dbend@voffset by 22% + \divide\dbend@voffset by 15% + \advance\dbend@voffset by -\baselineskip} +% +% This parts is hacked from TeXbook +% +\def\d@nger{\begingroup\clubpenalty=10000\def\par{\endgraf\endgroup} + \setdbend@width\noindent\hangindent\dbend@width\hangafter=-2 + \lower-\dbend@voffset\hbox to0pt{\hskip-\hangindent\dbend\hfill}} +% +\def\dd@nger{\begingroup\clubpenalty=10000\def\par{\endgraf\endgroup} + \setdbend@width\noindent\hangindent\ddbend@width\hangafter=-2 + \lower-\dbend@voffset\hbox to0pt{\hskip-\hangindent\dbend\kern1pt\dbend\hfill}} +% +\def\danger{\d@nger} +\def\ddanger{\dd@nger} +\def\enddanger{\endgraf\endgroup} +% +% +\newenvironment{advanced}{\CJKfamily{kai}}{\CJKfamily{com}} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Typesetting Questions +% +% +\setcounter{tocdepth}{3} +\setcounter{secnumdepth}{3} +\renewcommand\appendix{\par\setcounter{secnumdepth}{-1}} +% +% tableofcontents definition from article.cls +\renewcommand\tableofcontents{% + \pdfbookmark[1]{\contentsname}{contents}% + \section*{\contentsname + \@mkboth{% + \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% + \@starttoc{toc}% + } +% +% thebibliography definition from article.cls +\renewenvironment{thebibliography}[1] + {\section{\refname}% + \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}% + \list{\@biblabel{\@arabic\c@enumiv}}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \sloppy + \clubpenalty4000 + \@clubpenalty \clubpenalty + \widowpenalty4000% + \sfcode`\.\@m} + {\def\@noitemerr + {\@latex@warning{Empty `thebibliography' environment}}% + \endlist} +% +% theindex definition from article.cls +\renewenvironment{theindex} + {\if@twocolumn + \@restonecolfalse + \else + \@restonecoltrue + \fi + \columnseprule \z@ + \columnsep 35\p@ + \twocolumn[\section{\indexname}]% + \@mkboth{\MakeUppercase\indexname}% + {\MakeUppercase\indexname}% + \thispagestyle{plain}\parindent\z@ + \parskip\z@ \@plus .3\p@\relax + \let\item\@idxitem} + {\if@restonecol\onecolumn\else\clearpage\fi} +% +% section definition from article.cls +\renewcommand\section{\@startsection {section}{\@ne}{\z@}% + {-3.5ex \@plus -1ex \@minus -.2ex}% + {2.3ex \@plus .2ex}% + {\normalfont\Large\bfseries}} +\renewcommand*\l@section[2]{% + \ifnum \c@tocdepth >\z@ + \addpenalty\@secpenalty + \addvspace{1.0em \@plus\p@}% + \setlength\@tempdima{1.5em}% + \begingroup + \parindent \z@ \rightskip \@pnumwidth + \parfillskip -\@pnumwidth + \leavevmode \bfseries + \advance\leftskip\@tempdima + \hskip -\leftskip + #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par + \endgroup + \fi} +% +% This parts is hacked from faq.sty of UKTUG +% +% subsections: these are a curious half-breed between latex sections +% and subsections -- as designed, i'm not intending there ever to be +% more than 9 per section (hahaha) +\renewcommand\subsection{\@startsection{subsection}{\tw@}{\z@}% + {-3.25ex\@plus -1ex \@minus -.2ex}% + {1.5ex \@plus .2ex}% + {\normalfont\large\bfseries}} +\renewcommand*\l@subsection[2]{% + \ifnum \c@tocdepth >\@ne + \addpenalty\@secpenalty + \addvspace{0.5em \@plus\p@}% + \setlength\@tempdima{2.3em}% + \begingroup + \parindent \z@ \rightskip \@pnumwidth + \parfillskip -\@pnumwidth + \leavevmode \bfseries + \advance\leftskip\@tempdima + \hskip -\leftskip + #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par + \endgroup + \fi} +% +% +% the question structure +% +\ifx\faqlastver\undefined + \let\faqlastver\faqversion +\fi +% +% +\newcommand\listofnewfaqs{\@starttoc{lon}} +\newcommand\listofrevfaqs{\@starttoc{lor}} +\newcommand\tableofnewfaqs{\@starttoc{ton}} +\newcommand\tableofrevfaqs{\@starttoc{tor}} +% +% + +\newcommand{\FAQChangeList}{\clearpage% + \ifx\faqlastver\faqversion + \section{ChangeList of v\faqversion} + \else + \section{ChangeList of v\faqlastver\ --\ v\faqversion} + \fi + \subsection*{New}\begin{small}\tableofnewfaqs\end{small} + \subsection*{Revised}\begin{small}\tableofrevfaqs\end{small} + \vspace{\stretch{1}} + \ifx\RCSDate\undefined\else + \noindent\begin{small}(Last updated: \CTEXoptions[today=small]\RCSDate)\end{small} + \fi} +% +% +\newif\ifquestion@new +\question@newfalse +\def\question@ver#1.#2|#3.#4\@nil{% + \question@newtrue + \ifnum#3<#1 \question@newfalse + \else \ifnum#3=#1 \ifnum#4<#2 \question@newfalse \fi \fi + \fi} +\def\question@chk#1#2#3#4#5#6{% + \expandafter\question@ver\faqlastver|#6\@nil% + \ifquestion@new + \addtocontents{#1}{\protect\ref{#4}} + \addcontentsline{#2}{question}{\protect\numberline{\thequestion}#5} + \ifnewfaqmark + \marginpar{\vspace{-1em}\small\sffamily\raggedright{\color{red}#3}\\v#6} + \fi + \fi} +% +% +% Question[label name]{question asked}{imported version}{revised version} +% if [label name] present, the named label is assigned with Qlabel +\newcounter{question} +\newcommand\Question[4][]{% + \qu@stion{#2}% + \def\reserved@a{#1}% + \ifx\reserved@a\@empty + \PackageWarning{ctex-faq}{Question "#2" has no label}% + \def\reserved@a{Q-\thequestion} + \fi + \Qlabel{\reserved@a}% + \question@chk{lon}{ton}{New}{\reserved@a}{#2}{#3} + \ifquestion@new\else + \question@chk{lor}{tor}{Revised}{\reserved@a}{#2}{#4} + \fi +} +\newcommand\qu@stion{\@startsection{question}{\thr@@}{\z@}% + {-3.25ex \@plus -1ex \@minus -.2ex}% + {0.75ex \@plus .2ex}% + {\normalfont\normalsize\bfseries}% +} +\newcommand*\questionmark[1]{} +\newcommand*\l@question{\@dottedtocline{2}{2.0em}{2.3em}} +\newcommand*\toclevel@question{2} +% +% +% Qlabel and Qref: define and refer to labels +\def\Qname{Question} +% hyperref version of label doesn't get set until begin document +\AtBeginDocument{\let\Qlabel\label} +\newcommand\Qref[2][\Qname]{{#1}~\ref{#2}} +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +\endinput +%% +%% End of file `ctex-faq.sty'. |