LibreOffice Writer Variables and Statistics Fields
LibreOffice Writer allows users to automate dynamic content and track document metrics using built-in field commands. This guide details the user-defined variables and document statistics fields available in LibreOffice Writer, explains their functions, and outlines how to insert them directly into your text.
How to Access the Fields Dialog
To access all available fields in LibreOffice Writer, navigate to Insert > Field > More Fields… from the top menu, or press the shortcut key Ctrl + F2 (Command + F2 on macOS). The dialog is divided into tabs, primarily Variables and DocInformation (or Document), which contain variables and statistics respectively.
User-Defined Variables
User-defined variables allow you to store, calculate, and display custom information across your document. These are located in the Variables tab of the Fields dialog:
- Set Variable: Assigns a specific value or string to a named variable. The variable can remain hidden or be printed at the insertion point.
- Show Variable: Displays the current value of a previously defined “Set Variable” elsewhere in the document.
- User Field: Creates a custom data field that can hold custom text, numbers, or dates. Unlike “Set Variable”, User Fields are globally defined for the document and can be formatted using standard LibreOffice formatting codes.
- Input Field: Prompts the user with an interactive pop-up box to enter or edit the value of an assigned variable or User Field directly from the document body.
- Number Range: Generates automatic, sequential numbering sequences for custom categories (such as Illustrations, Figures, Tables, or custom sequences like Step numbers).
- Insert Formula: Performs mathematical calculations using numbers, basic operators, and existing variables within your document text.
- DDE Command (Dynamic Data Exchange): Dynamically imports and updates data from external applications, such as a cell range in a LibreOffice Calc spreadsheet.
Document Statistics Fields
Document statistics fields dynamically pull real-time metadata and metrics about the document. These can be found under the Document or DocInformation tab (under the Document Statistics or Statistic type):
- Pages: Inserts the total page count of the document.
- Words: Inserts the total number of words in the document.
- Characters: Inserts the total character count (including or excluding spaces, depending on the format selected).
- Paragraphs: Displays the total number of distinct paragraph breaks.
- Tables: Outputs the total number of tables embedded in the document.
- Graphics / Images: Counts the total number of inserted images and graphics.
- Objects: Displays the total count of embedded OLE objects, charts, and drawings.
Steps to Insert Variables and Statistics
- Place your cursor in the document where you want the dynamic field to appear.
- Press Ctrl + F2 to open the Fields window.
- Choose the Variables tab for custom variables, or the DocInformation / Document tab for document statistics.
- Select the desired Type from the left list and choose the specific Select property or format from the right columns.
- Enter any required names or initial values in the input boxes at the bottom.
- Click Insert, then click Close.