### Dynamic CJK Font Setup with zhmCJK Source: https://context7.com/leo-liu/tex-pkg/llms.txt Configures CJK fonts for pdfTeX and DVIPDFMx using xeCJK-like syntax. This example sets main, sans-serif, and monospace CJK fonts, including bold and italic variants. ```latex % UTF-8 encoding required % Compile with: pdflatex or latex + dvipdfmx \documentclass[12pt,a4paper]{article} \usepackage{zhmCJK} % Set main CJK font with bold and italic variants \setCJKmainfont{simsun.ttc}[ BoldFont=simhei.ttf, ItalicFont=simkai.ttf ] % Set sans-serif CJK font (disable auto bold) \setCJKsansfont{simhei.ttf}[AutoFakeBold=0] % Set monospace CJK font (enable auto slant) \setCJKmonofont{simfang.ttf}[AutoFakeSlant] % Define custom font family \setCJKfamilyfont{yahei}{msyh.ttc}[BoldFont=msyhbd.ttc] \begin{document} Normal text in Song font. \textbf{Bold becomes Hei font.} \textit{Italic becomes Kai font.} \textsf{Sans-serif is Hei font, \textbf{no auto bold}.} \texttt{Monospace is FangSong, \textsl{with auto slant}.} {\CJKfamily{yahei}Microsoft YaHei font family} \end{document} ``` -------------------------------- ### Configure diagbox layout options Source: https://context7.com/leo-liu/tex-pkg/llms.txt Provides examples for controlling diagonal direction, explicit dimensions, inner width, margins, and trimming for specific column types. ```latex \documentclass{article} \usepackage{diagbox} \begin{document} % Direction options: NW (default), NE, SW, SE \begin{tabular}{|c|c|} \hline \diagbox[dir=NW]{A}{B} & \diagbox[dir=NE]{A}{B} \\ \hline \diagbox[dir=SW]{A}{B} & \diagbox[dir=SE]{A}{B} \\ \hline \end{tabular} % Explicit width and height (use \line for line height) \begin{tabular}{|c|} \hline \diagbox[width=4cm,height=3\line]{line\\heads}{column\\heads} \\ \hline \end{tabular} % Inner width for column width matching \begin{tabular}{|p{2cm}|} \hline \diagbox[innerwidth=2cm]{A}{B} \\ \hline \end{tabular} % Margin controls \begin{tabular}{|c|} \hline \diagbox[innerleftsep=.5cm,innerrightsep=0pt]{A}{B} \\ \hline \end{tabular} % Trim option for @{} column specifiers \begin{tabular}{|@{}c@{}|} \hline \diagbox[trim=lr]{Left}{Right} \\ \hline \end{tabular} \end{document} ``` -------------------------------- ### Use slashbox compatibility commands Source: https://context7.com/leo-liu/tex-pkg/llms.txt Shows how to use legacy \backslashbox and \slashbox commands provided by diagbox for backward compatibility. ```latex \documentclass{article} \usepackage{diagbox} % Automatically prevents slashbox loading \begin{document} % Legacy slashbox syntax (compatible mode) \begin{tabular}{|c|c|c|} \hline \backslashbox[2cm]{num}{alpha} & A & B \\ \hline 1 & A1 & B1 \\ \hline 2 & A2 & B2 \\ \hline \end{tabular} % slashbox creates SW diagonal (opposite direction) \begin{tabular}{|c|c|c|} \hline \slashbox[2cm]{num}{alpha} & A & B \\ \hline 1 & A1 & B1 \\ \hline \end{tabular} % Modern equivalent using diagbox \begin{tabular}{|c|c|c|} \hline \diagbox[width=2cm,dir=SW]{num}{alpha} & A & B \\ \hline \end{tabular} \end{document} ``` -------------------------------- ### Basic seealso Usage with Page Numbers Source: https://context7.com/leo-liu/tex-pkg/llms.txt Demonstrates the basic functionality of the seealso package, automatically adding page numbers to index entries and preventing duplicate references. Load seealso after makeidx. ```latex \documentclass{article} \usepackage{makeidx} \usepackage{seealso} % Must load after makeidx \makeindex \begin{document} % Basic usage - page numbers are automatically added On page 1, we discuss math.\index{math|see{mathematics}} \newpage On page 2, more math content.\index{math|see{mathematics}} \newpage On page 3, final math section.\index{math|see{mathematics}} % Output in index will be: % math, see mathematics 1, 2, 3 % (instead of: math, see mathematics, see mathematics, see mathematics) % Using seepage and seealsopage explicitly \index{algebra|seepage{mathematics}} \index{calculus|seealsopage{analysis}} % Multiple different cross-references \index{foo|seepage{bar}} \index{foo|seepage{foobaz}} % Output: foo, see bar 1, see foobaz 3 \printindex \end{document} ``` -------------------------------- ### zhmCJK Package Options and Font Configuration Source: https://context7.com/leo-liu/tex-pkg/llms.txt Demonstrates various package options for zhmCJK, including encoding, fake bold/slant effects, and font embedding. It also shows an alternative syntax for font options and how to change default font families. ```latex \documentclass{article} % Package options \usepackage[ encoding=UTF8, % Input encoding (UTF8, GBK, Bg5, etc.) AutoFakeBold=0.4, % Global fake bold width (0 to disable) AutoFakeSlant=0.167, % Global fake slant angle (0 to disable) pdffakebold=true, % Use PDF primitives for fake bold cmap=unicode, % CMap for DVIPDFMx (unicode, UniGB-UTF16-H) embed=true % Embed fonts (DVIPDFMx only) ]{zhmCJK} % Font options - alternative syntax (options after font name) \setCJKmainfont{FandolSong-Regular.otf}[ cmap=UniGB-UTF16-H, BoldFont=FandolSong-Bold.otf, ItalicFont=FandolKai-Regular.otf, BoldItalicFont=FandolHei-Bold.otf, SlantedFont=FandolFang-Regular.otf, encoding=UTF8, AutoFakeBold=0.5, AutoFakeSlant=0.2 ] % Default font family names % \CJKrmdefault -> "rm" (for \rmfamily) % \CJKsfdefault -> "sf" (for \sffamily) % \CJKttdefault -> "tt" (for \ttfamily) % \CJKfamilydefault -> \CJKrmdefault (for \normalfont) \begin{document} % Change default to sans-serif \renewcommand\familydefault{\sfdefault} \renewcommand\CJKfamilydefault{\CJKsfdefault} % Manual bold/slant control \CJKbold % Enable fake bold \CJKslant % Enable fake slant \CJKboldslant % Enable both \CJKnormal % Reset to normal Chinese text here. \end{document} ``` -------------------------------- ### seealso Output Customization with \seealsosetup Source: https://context7.com/leo-liu/tex-pkg/llms.txt Illustrates how to customize the appearance of cross-references in the index using \seealsosetup. This includes formatting page numbers, changing separators, and disabling page number output. ```latex \documentclass{article} \usepackage{makeidx} \usepackage{seealso} \makeindex \begin{document} % Set page numbers to italic for "see also" references \seealsosetup[also]{pageformat=\textit{#1}} % Customize separators globally \seealsosetup{ listsep={;\space}, % Before see list itemsep={,\space}, % Between items nameformat={\textsc{#1}\space} % Format "see" name } % Disable page number output (show only cross-reference) \seealsosetup[see,also]{pageformat=\SeealsoGobble{,}} % Define custom cross-reference commands \DeclareSeealsoMacro\seepage{see}{see} \DeclareSeealsoMacro\seealsopage{also}{see also} % Package options % \usepackage[override=false]{seealso} % Don't override \see, \seealso % \usepackage[activecr=false]{seealso} % Manual list output % Manual list output when activecr=false % Add to makeindex style file: % delim_t "\\SeealsoPrintList" \index{example|seepage{sample}} See the example here. \printindex \end{document} ``` -------------------------------- ### Create diagonal table headers with diagbox Source: https://context7.com/leo-liu/tex-pkg/llms.txt Demonstrates basic two-part and three-part diagonal headers, along with advanced styling options like width, direction, line color, and font customization. ```latex \documentclass{article} \usepackage{diagbox} \begin{document} % Basic two-part diagonal header \begin{tabular}{|l|ccc|} \hline \diagbox{Time}{Day} & Mon & Tue & Wed \\ \hline Morning & used & used & \\ Afternoon & & used & used \\ \hline \end{tabular} % Three-part header with two diagonal lines \begin{tabular}{|l|ccc|} \hline \diagbox{Time}{Room}{Day} & Mon & Tue & Wed \\ \hline Morning & A101 & B202 & C303 \\ Afternoon & D404 & E505 & F606 \\ \hline \end{tabular} % Advanced options: width, direction, line styling \begin{tabular}{|@{}l|c|c|r@{}|} \hline \diagbox[width=5em,trim=l]{Time}{Day} & Mon & Tue & Wed\\ \hline Morning & used & used & used\\ \hline Afternoon & & used & \diagbox[dir=SW,height=2em,trim=r]{A}{B} \\ \hline \end{tabular} % Line customization with color and width \begin{tabular}{|c|} \hline \diagbox[linewidth=2pt,linecolor=blue]{AAA}{BBB} \\ \hline \end{tabular} % Font customization \begin{tabular}{|c|} \hline \diagbox[font=\footnotesize\itshape]{Small}{Italic} \\ \hline \end{tabular} \end{document} ``` -------------------------------- ### Implement Encoding Autodetection with autozhenc Source: https://context7.com/leo-liu/tex-pkg/llms.txt Automatically switch between UTF-8 and legacy encodings like GBK based on character detection. ```latex \documentclass{article} % Option is a single Chinese character for testing \usepackage[]{autozhenc} % After loading, check encoding \ifUTF \usepackage[UTF8]{ctex} \else \usepackage[GBK]{ctex} \fi % Or use the detected encoding directly % \autozhenc expands to "UTF8" or \fallbackzhenc \begin{document} % Runtime test with different character \testzhenc{} Detected encoding: \autozhenc % Customize fallback encoding (default is GBK) \def\fallbackzhenc{Bg5} \end{document} ``` -------------------------------- ### Configure Plain TeX CJK Support with zhtex Source: https://context7.com/leo-liu/tex-pkg/llms.txt Use this configuration to enable UTF-8 Chinese character support in Plain TeX documents, specifically for MetaPost integration. ```tex % Plain TeX file with Chinese support \input zhtex.tex % Configure font and size \def\zhfont{gbsnu} % Font name prefix \def\zhsize{12} % Font size in points % Custom inter-character spacing \def\skipzh{\hskip 0em plus 0.2em minus 0.1em} % Now Chinese characters can be used directly (UTF-8) This is English text with Chinese characters. \bye ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.