TeXipedia

textunderscore

Produces a text-mode underscore character that can be used within regular text or mathematical environments.

Overview

Serves as a proper typographical underscore character, particularly useful when underscores are needed in text without creating subscripts or other unintended formatting effects.

  • Commonly used in file names, URLs, or computer code references within documents
  • Provides a safer alternative to the direct underscore character (_) which can cause formatting issues
  • Essential for technical documentation where precise underscore rendering is required
  • Often employed in cross-referencing systems or when citing digital resources

Examples

Displaying a variable name with underscores in text mode.

Thevariablenameismy_variableThe variable name is \text{my\textunderscore variable}
The variable name is \text{my\textunderscore variable}

Showing a file path in a document.

Savethefilein:C:__data__Save the file in: \text{C:\textunderscore\textunderscore data\textunderscore\textunderscore}
Save the file in: \text{C:\textunderscore\textunderscore data\textunderscore\textunderscore}

Formatting a URL-safe string.

Theslugformatis:how_to_latexThe slug format is: \text{how\textunderscore to\textunderscore latex}
The slug format is: \text{how\textunderscore to\textunderscore latex}