Tag
Macros
- Why Can’t I Use \DeclareMathOperator{\H}{\mathbb H}?The command \H is already reserved for a Hungarian accent. Use a fresh symbol macro for blackboard-bold H, and reserve \DeclareMathOperator for operators.
- Why Does LaTeX Say “Macro Parameter # in Vertical Mode”?This LaTeX error usually means a literal # appeared outside a macro definition; write \# for a hash or ## for nested macro parameters.
- Where Should You Put LaTeX Macro Package Files?Put reusable LaTeX .sty files in a personal texmf tree or beside a project’s main file; use the correct folder structure and refresh the file database if needed.
- How Does the LaTeX \@for Loop Work?Learn the syntax of LaTeX's internal \@for loop, see a complete working example, and avoid common mistakes with commas and @.
- How to Remove Extra Space After a LaTeX Section TitleExtra space after a LaTeX section title usually comes from spacing added by a custom command; find and remove it or set heading spacing consistently.
- How to Use \item in a LaTeX trivlistIn LaTeX, use \item inside trivlist to begin each entry; add an optional bracketed label for a custom heading or leave it empty.
- How to Put Two Minipages Inside a LaTeX CommandDefine a two-argument LaTeX command with one minipage per argument, using less than half the line width for each box.
- How to Define a Command for Italic Text in LaTeXDefine an italic-text command with \newcommand and the right argument count; use a math-mode command instead when formatting symbols.
- How to Add Remarks with the LaTeX changes PackageUse the changes package's comment command for review notes, and an amsthm remark environment for remarks that belong in the final document.
- How to Replace Repeated Text with a LaTeX MacroUse a LaTeX macro to manage repeated text, or use your editor’s find-and-replace feature to change existing literal phrases in the source.
- How Do I Reset a LaTeX \renewcommand?To undo a LaTeX \renewcommand, limit the redefinition to a group or save the original definition and restore it explicitly when you need it later.
- How to Use Commands in PyLaTeXUse PyLaTeX's Command class for LaTeX commands, and add custom macro definitions to the preamble with NoEscape.
- How to Define and Typeset Your Own Function in LaTeXDefine a mathematical function with standard notation, or create a reusable LaTeX command that typesets its name and input with correct spacing.
- How to Insert Red XXX Placeholders with a LaTeX CommandDefine a reusable LaTeX command with xcolor to insert one or more red XXX placeholders, then use the command wherever needed.
- How to Define a LaTeX Command for a Ket-BraDefine a reusable LaTeX ket-bra command for the Dirac outer product, with a minimal compilable example, spacing guidance, and a scalable-delimiter variant.
- How Can You Define a LaTeX Command with a Variable Number of Arguments?LaTeX \newcommand takes a fixed number of arguments; represent variable-length input as a list or parse repeated groups with a clear terminator.
- How to Show or Hide Optional Text in LaTeXUse a LaTeX Boolean switch to show or hide optional text, set its default state, and change the setting temporarily in a group.
- How to Wrap an enumitem List in a LaTeX MacroDefine a reusable enumerate environment with enumitem options by forwarding an optional argument and, if useful, setting a default label.
- How to Add a Short Abstract After a LaTeX Part HeadingDefine a LaTeX command that prints a part heading followed by a short, consistently formatted abstract, with a complete example you can compile.
- How to Change the Margins in a LaTeX EnvironmentUse the changepage package’s adjustwidth environment inside newenvironment to inset text locally, or use geometry to change page margins globally.
- How Are LaTeX Class Files and Style Files Structured?A LaTeX class file defines a document type, while a style file adds features. Learn the standard declarations, loading commands, and a working example.
- How to Change Line Spacing in a Shortstack-Like BoxUse a one-column tabular box instead of \shortstack, then adjust its row spacing with a local \arraystretch value or a row-specific gap.
- Fix an Extra } Error When Using a Custom Command in \ulRegister your custom macro with soul using its number of mandatory arguments; this lets \ul parse the command and its argument correctly.
- How to Add a Border or Frame Around a Box in LaTeXUse \fbox for a simple LaTeX border, or frame a minipage for paragraphs; control padding and line thickness with \fboxsep and \fboxrule.