### Configure global settings with \CodeHigh Source: https://context7.com/lvjr/codehigh/llms.txt Sets global options for language selection and style customization for all subsequent codehigh environments. ```latex \documentclass{article} \usepackage{codehigh} \begin{document} % Set default language and customize colors \CodeHigh{language=latex/table,style/main=yellow9,style/code=red9,style/demo=azure9} % All subsequent environments use these settings \begin{demohigh} \begin{tabular}{lccr} \hline Alpha & Beta & Gamma & Delta \\ \hline \end{tabular} \end{demohigh} % Reset to default gray theme \CodeHigh{language=latex,style/main=gray9,style/code=gray9,style/demo=white} \end{document} ``` -------------------------------- ### Display code with visible spaces and output with demohigh* Source: https://context7.com/lvjr/codehigh/llms.txt The demohigh* environment combines visible space rendering with the side-by-side code and output display. ```latex \documentclass{article} \usepackage{codehigh} \begin{document} % Shows both code with visible spaces and the output \begin{demohigh*}[language=latex/table] \begin{tabular}{lc} \hline Item & Value \\ \hline \end{tabular} \end{demohigh*} \end{document} ``` -------------------------------- ### \CodeHigh Command Source: https://context7.com/lvjr/codehigh/llms.txt Sets global configuration options for all subsequent codehigh environments, including language and style settings. ```APIDOC ## \CodeHigh ### Description Configures global settings for the package. ### Parameters - **options** (required) - Comma-separated list of settings (e.g., language, style/main, style/code, style/demo, theme). ``` -------------------------------- ### \dochighinput Command Source: https://context7.com/lvjr/codehigh/llms.txt Reads and highlights an external file with syntax highlighting. Supports literate programming via special comment markers. ```APIDOC ## \dochighinput ### Description Reads and highlights an external file. Lines starting with %%% are omitted, and lines starting with %%> are typeset as normal text. ### Parameters - **[options]** (optional) - Key-value pairs for language selection (e.g., language=latex/latex3). - **filename** (required) - The path to the file to be highlighted. ``` -------------------------------- ### Display code and output side-by-side with demohigh Source: https://context7.com/lvjr/codehigh/llms.txt The demohigh environment renders both the source code and its typeset output. If the combined width exceeds the line width, the output is placed below the code. ```latex \documentclass{article} \usepackage{codehigh} \begin{document} % Side-by-side code and output (if width permits) \begin{demohigh}[language=latex/table] \begin{tabular}{lccr} \hline Alpha & Beta & Gamma & Delta \\ \hline Epsilon & Zeta & Eta & Theta \\ \hline \end{tabular} \end{demohigh} % Wider tables will have output below the code \begin{demohigh}[language=latex/table] \begin{tabular}{llccrr} \hline Alpha & Beta & Gamma & Delta & Epsilon & Zeta \\ \hline Eta & Theta & Iota & Kappa & Lambda & Mu \\ \hline \end{tabular} \end{demohigh} \end{document} ``` -------------------------------- ### Define custom syntax rules with \AddCodeHighRule Source: https://context7.com/lvjr/codehigh/llms.txt Creates syntax highlighting rules for custom languages using regex patterns and type numbers for styling. ```latex \documentclass{article} \usepackage{codehigh} \begin{document} % Define a custom language for highlighting \AddCodeHighRule[mylang]{1}{Keyword} {\\(if|then|else|end)} \AddCodeHighRule[mylang]{2}{Function} {\\[A-Za-z]+} \AddCodeHighRule[mylang]{3}{Number} {\d+} \AddCodeHighRule[mylang]{9}{Comment} {\%.*?\n} % Use the custom language \begin{codehigh}[language=mylang] \if condition \then \dosomething 123 \else \doother 456 \end{if} % This is a comment \end{codehigh} \end{document} ``` -------------------------------- ### Display code with visible spaces using codehigh* Source: https://context7.com/lvjr/codehigh/llms.txt The codehigh* environment renders space characters as visible symbols, useful for demonstrating whitespace-sensitive code. ```latex \documentclass{article} \usepackage{codehigh} \begin{document} % Shows spaces as visible characters \begin{codehigh*} \newcommand{\test}{Hello World} indented line with spaces \end{codehigh*} \end{document} ``` -------------------------------- ### \AddCodeHighRule Command Source: https://context7.com/lvjr/codehigh/llms.txt Defines custom syntax highlighting rules for specific languages using regex patterns. ```APIDOC ## \AddCodeHighRule ### Description Registers a new syntax rule for a custom language. ### Parameters - **[language]** (optional) - The name of the custom language. - **type** (required) - Integer representing the color style index. - **name** (required) - Name of the rule. - **pattern** (required) - Regex pattern to match. ``` -------------------------------- ### \SetCodeHighStyle and \GetCodeHighStyle Commands Source: https://context7.com/lvjr/codehigh/llms.txt Manages color themes by mapping rule type numbers to specific colors. ```APIDOC ## \SetCodeHighStyle ### Description Defines color styles for a theme. ### Parameters - **[theme]** (optional) - Name of the theme. - **element** (required) - The element to style (main, code, demo, or rule type number). - **color** (required) - The color name (e.g., blue9). ``` -------------------------------- ### \fakeverb Command Source: https://context7.com/lvjr/codehigh/llms.txt Typesets verbatim-like content inside environments where standard verbatim fails, such as tabularx or fbox. ```APIDOC ## \fakeverb ### Description Provides verbatim-like typesetting with support for escaping special characters. ### Parameters - **content** (required) - The text to be typeset verbatim. ``` -------------------------------- ### Display syntax-highlighted code with codehigh Source: https://context7.com/lvjr/codehigh/llms.txt Use the codehigh environment to highlight various LaTeX language variants including standard, package, LaTeX3, math, and table code. ```latex \documentclass{article} \usepackage{codehigh} \begin{document} % Basic code highlighting with default latex language \begin{codehigh} \documentclass{article} \usepackage[a4paper,margin=2cm]{geometry} \usepackage{codehigh} \newcommand*{\myversion}{2025C} \begin{document} % This is a comment \section{Section Name} Math: $a+b=c$ \end{document} \end{codehigh} % Code highlighting with latex/latex2 language (for package development) \begin{codehigh}[language=latex/latex2] \def\abcd#1#2{ % some comment \unskip \setlength{\parindent}{0pt}% \let\item=\my@item@temp } \end{codehigh} % Code highlighting with latex/latex3 language \begin{codehigh}[language=latex/latex3] \cs_new_protected:Npn \__codehigh_typeset_demo: { \__codehigh_build_code: \dim_set:Nn \l_tmpa_dim { \box_wd:N \g__codehigh_code_box } \par\addvspace{0.5em}\noindent } \end{codehigh} % Code highlighting for math mode \begin{codehigh}[language=latex/math] \begin{align} \pi\left[\frac13z^3\right]\sin(2x+1)_0^4 = \frac{64}{3}\pi \end{align} \end{codehigh} % Code highlighting for tables \begin{codehigh}[language=latex/table] \begin{tabular}[b]{|lc|r|} \hline One & Two & Three \\ Four & Five & Six \\ \hline \end{tabular} \end{codehigh} \end{document} ``` -------------------------------- ### Highlight external files with \dochighinput Source: https://context7.com/lvjr/codehigh/llms.txt Reads and highlights external files. Supports special comment markers for omitting lines or typesetting documentation. ```latex \documentclass{article} \usepackage{codehigh} \begin{document} % Input and highlight an external LaTeX3 package file \dochighinput[language=latex/latex3]{codehigh.sty} % Input with default latex language \dochighinput{myfile.tex} % The source file can contain special comment markers: % %%% This line will be omitted from output % %%> \section{Documentation Section} % %%> This text will be typeset as normal LaTeX \end{document} ``` -------------------------------- ### Predefined Languages Source: https://context7.com/lvjr/codehigh/llms.txt CodeHigh provides five predefined languages for syntax highlighting, each with specific rules and color assignments for different LaTeX content types. ```APIDOC ## Predefined Languages ### Description CodeHigh offers five predefined languages for highlighting various LaTeX content types. Each language has optimized rules and distinct color assignments for syntactic elements. ### Method LaTeX Environment Option ### Endpoint N/A (LaTeX Environment Option) ### Parameters #### `codehigh` Environment Option - **language** (string) - Optional - Specifies the language for highlighting. Defaults to `latex`. - `latex`: Default highlighting for general LaTeX code. - `latex/latex2`: For LaTeX2e package/class development. - `latex/latex3`: For LaTeX3/expl3 code. - `latex/math`: For mathematical environments. - `latex/table`: For tabular environments. ### Request Example ```latex % Use the latex/latex3 language for highlighting \begin{codehigh}[language=latex/latex3] % Your LaTeX3 code here \end{codehigh} % Use the default latex language \begin{codehigh}[language=latex] % Your LaTeX code here \end{codehigh} ``` ### Response N/A (This is an environment that renders highlighted code) ### Response Example N/A ``` -------------------------------- ### Using Predefined Languages in CodeHigh Source: https://context7.com/lvjr/codehigh/llms.txt Specify the language for highlighting using the 'language' option in the codehigh environment. The default is 'latex'. ```latex % language=latex (default) % Highlights: Package, NewCommand, SetCommand, BeginEnd, Section, Command, Brace, MathMode, Comment ``` ```latex % language=latex/latex2 (for LaTeX2e package/class development) % Highlights: Argument (#1), NewCommand (\def, \edef), SetCommand, PrivateCmd (@), Command, Brace, Bracket, Comment ``` ```latex % language=latex/latex3 (for LaTeX3/expl3 code) % Highlights: Argument (#1), PrivateVar (\l__), PrivateFun (\__), PublicVar (\l_), PublicFun, Brace, Bracket, Comment ``` ```latex % language=latex/math (for math environments) % Highlights: LeftRight, Command, MathMode, Script (_^), Number, Brace, Bracket, Parenthesis, Comment ``` ```latex % language=latex/table (for tabular environments) % Highlights: Newline (\\), Alignment (&), BeginEnd, Command, Brace, Bracket, Comment ``` ```latex \begin{codehigh}[language=latex] \documentclass{article} \begin{document} Hello World \end{document} \end{codehigh} ``` -------------------------------- ### Customize themes with \SetCodeHighStyle Source: https://context7.com/lvjr/codehigh/llms.txt Maps rule type numbers to color names to define custom themes for codehigh environments. ```latex \documentclass{article} \usepackage{codehigh} \begin{document} % Define custom theme colors \SetCodeHighStyle[mytheme]{main}{blue9} % main container background \SetCodeHighStyle[mytheme]{code}{cyan9} % code area background \SetCodeHighStyle[mytheme]{demo}{white} % demo area background \SetCodeHighStyle[mytheme]{0}{black} % default text \SetCodeHighStyle[mytheme]{1}{red3} % rule type 1 \SetCodeHighStyle[mytheme]{2}{green3} % rule type 2 \SetCodeHighStyle[mytheme]{9}{gray3} % comments (type 9) % Apply the custom theme \CodeHigh{theme=mytheme} \begin{codehigh} \documentclass{article} % This comment uses type 9 color \end{codehigh} \end{document} ``` -------------------------------- ### Typeset verbatim content with \fakeverb Source: https://context7.com/lvjr/codehigh/llms.txt Allows verbatim-like typesetting inside environments where standard verbatim fails. Special characters must be escaped with backslashes. ```latex \documentclass{article} \usepackage{codehigh} \usepackage{tabularx} \begin{document} % Using \fakeverb inside tabularx \begin{tabularx}{0.5\textwidth}{lX} \hline Alpha & \fakeverb{\abc{}$&^_^uvw 123} \\ \hline Beta & \fakeverb{\bfseries\ \#\%} \\ \hline \end{tabularx} % Using \fakeverb inside \fbox Hello\fbox{\fakeverb{$\left\\\{A\right.$\#}}Verb! % Escape sequences: % \\\\ -> \ (backslash, only when escaping other symbols) % \\\{ -> { (unmatched braces) % \\\} -> } (unmatched braces) % \\\# -> # (always escape) % \\\^ -> ^ (multiple in a row) % \\ -> space (multiple spaces or after control words) % \\\% -> % (always escape) \end{document} ``` -------------------------------- ### Enable/Disable CodeHigh Tracing Source: https://context7.com/lvjr/codehigh/llms.txt Use \SetCodeHighTracing to control debug tracing for different components. Enable all tracing with 'all', specific components with '+component', or disable with '-component' or 'none'. ```latex \SetCodeHighTracing{all} ``` ```latex \SetCodeHighTracing{+code} ``` ```latex \SetCodeHighTracing{+demo} ``` ```latex \SetCodeHighTracing{+parser} ``` ```latex \SetCodeHighTracing{-code} ``` ```latex \SetCodeHighTracing{-parser} ``` ```latex \SetCodeHighTracing{none} ``` -------------------------------- ### SetCodeHighTracing Command Source: https://context7.com/lvjr/codehigh/llms.txt The \SetCodeHighTracing command allows enabling or disabling debug tracing for various components of the codehigh package to assist in troubleshooting. ```APIDOC ## \SetCodeHighTracing Command ### Description Enables or disables debug tracing for different components of the package. Useful for troubleshooting syntax highlighting issues or understanding parser behavior. ### Method LaTeX Command ### Endpoint N/A (LaTeX Command) ### Parameters #### Arguments - **option** (string) - Required - Specifies the tracing level. Can be `all`, `none`, `+component`, or `-component`. - `all`: Enable all tracing. - `none`: Disable all tracing. - `+component`: Enable tracing for a specific component (e.g., `+code`, `+demo`, `+parser`). - `-component`: Disable tracing for a specific component (e.g., `-code`, `-parser`). ### Request Example ```latex % Enable all tracing \SetCodeHighTracing{all} % Enable specific tracing \SetCodeHighTracing{+code} % Disable specific tracing \SetCodeHighTracing{-parser} ``` ### Response N/A (This is a command that modifies package behavior) ### Response Example N/A ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.