Skip to main content
v2026.11,986 entries · CC-BY 4.0

LaTeX Linewidth: How to Control Line Width and Sizing

Learn how LaTeX linewidth works, how it differs from textwidth and columnwidth, and how to scale figures and minipages across research layouts.

Written and maintained by CASRAI Editorial Board

Published

On this page

LaTeX linewidth (linewidth) is a core layout length parameter that represents the horizontal line width available in the current environment. Unlike static page dimensions, linewidth automatically adjusts when text enters indented environments like lists, quotes, or minipages, making it essential for scaling figures, tables, and side-by-side elements in academic manuscripts.

What it is used for in research

In scientific and technical research writing, document layout must frequently accommodate complex visual data, including multi-panel experimental plots, high-resolution microscope micrographs, and multi-column comparative tables. Academic journals typically enforce strict margin boundaries, whether publishing in single-column format (common in mathematical and theoretical monographs) or two-column format (standard for IEEE, ACM, and Nature journals).

The primary role of linewidth is context-sensitive element sizing. While researchers often default to textwidth, doing so frequently breaks layout geometry because textwidth measures the global width of the entire text body across the page. When typing inside an itemize list, an enumerated protocol, an indented blockquote, or a split-column box, the printable line width shrinks. Using linewidth guarantees that graphics and containers scale strictly to the horizontal boundary of their immediate surrounding context.

To choose the correct dimension for figures and tables, researchers must understand the distinction between LaTeX horizontal length variables:

Length Parameter Kernel Definition & Scope Behavior in Lists & Indented Blocks Multi-Column Layout (e.g. IEEEtran) Primary Research Use Case
linewidth Width of a line in the current environment; local and dynamic. Decreases by the sum of leftmargin and rightmargin. Equals columnwidth in body text; shrinks in nested blocks. Scaling figures, subfigures, minipages, and rules to fit current block.
textwidth Total width of the normal text body on the page; global and fixed. Constant; ignores list indentation and quotes. Spans across both columns plus the inter-column separation (columnsep). Setting full-page spans, two-column wide floats (figure*), or global geometry.
columnwidth Width of a single column of text; layout-level parameter. Constant; does not shrink within lists inside that column. Equals the exact single column width. Single-column figures in multi-column journal templates.
hsize Low-level TeX primitive line length; used by the TeX paragraph builder. Re-set by LaTeX kernel during environment transitions. Maintained by kernel routines for column building. Internal macro programming; avoid in standard author manuscripts.
paperwidth Physical width of the paper stock (e.g., 8.5 in for US Letter, 210 mm for A4). Constant throughout document. Constant throughout document. Package configuration (e.g., geometry) and poster production.

When formatting complex tables or multi-panel charts, pairing linewidth with specialized tabular configurations ensures cell contents and borders remain legible without margin clipping, as covered in our guide on centering table cell content vertically.

Install or access

The linewidth parameter is built directly into the LaTeX2e kernel. Authors do not need to import any third-party package to use linewidth for sizing graphics or declaring minipages. It is accessible across all modern TeX distributions and cloud platforms:

  • TeX Live: The standard cross-platform distribution maintained by the TeX Users Group (TUG), standard on Linux and Windows.
  • MacTeX: The macOS distribution bundling TeX Live, Ghostscript, and GUI utilities.
  • MiKTeX: An open-source distribution for Windows, Linux, and macOS with on-the-fly package installation.
  • Web Editors: Cloud-based scientific writing platforms such as Overleaf natively support all standard kernel lengths, as detailed in our review of web LaTeX editors for research.

If your journal submission requires reporting exact figure widths in absolute scientific units (such as millimeters or inches) to verify artwork guidelines, install the CTAN printlen package. Under TeX Live, install it via the package manager terminal command:

tlmgr install printlen

Step-by-step task

Follow these numbered steps to control document layout, inspect line lengths, and scale figures and boxes with linewidth.

Step 1: Check document geometry and column mode

Identify whether your target manuscript uses a single-column or two-column class. In your document preamble, establish your document class and import standard graphic handling packages:

documentclass[11pt,a4paper]{article}
usepackage{graphicx}
usepackage{printlen}

When importing external artwork files, refer to our comprehensive walkthrough on how to include graphics in LaTeX with the graphicx package.

Step 2: Size figures dynamically with linewidth

In the document body, embed figures using relative scaling factors based on linewidth rather than hard-coded absolute dimensions like width=12cm. For an illustration intended to span the full text width of the current column:

begin{figure}[htbp]
  centering
  includegraphics[width=linewidth]{figure1.pdf}
  caption{Experimental apparatus schematic scaled to full line width.}
  label{fig:apparatus}
end{figure}

To ensure robust citation and automated numbering of figures across document revisions, see our reference on cross-referencing in LaTeX.

Step 3: Structure side-by-side subfigures with minipages

When placing two graphs side by side, divide the line width proportionally between two minipage environments. Leave a safety fraction or an explicit horizontal fill (hfill) to prevent unexpected line breaking:

begin{figure}[htbp]
  centering
  begin{minipage}{0.48linewidth}
    includegraphics[width=linewidth]{plot_a.pdf}
    caption{Control group response.}
    label{fig:control}
  end{minipage}
  hfill
  begin{minipage}{0.48linewidth}
    includegraphics[width=linewidth]{plot_b.pdf}
    caption{Treated group response.}
    label{fig:treatment}
  end{minipage}
end{figure}

Notice that inside each minipage, the nested linewidth automatically resets to equal 0.48linewidth of the parent container. Thus, specifying width=linewidth on the inner includegraphics scales the plot to 100% of that minipage.

Step 4: Inspect and measure exact linewidth values

To verify the exact dimensions of your manuscript columns for artwork preparation in Python, Matplotlib, or R, inspect the numerical value of linewidth directly in your compiled output:

% Native TeX inspection (prints value in points, pt)
The current line width is: thelinewidth.

% Using CTAN printlen for physical units
uselengthunit{mm}
Current line width in millimeters: printlength{linewidth}.

uselengthunit{in}
Current line width in inches: printlength{linewidth}.

Authors defining custom shorthand macros for recurring layout measurements can streamline their code by using LaTeX newcommand definitions.

Output and how to read it

When compiling the diagnostic commands, LaTeX outputs the computed dimension based on the active font size and page geometry:

  • Points (pt): A standard single-column article on A4 paper with default 10pt font yields a thelinewidth output of approximately 345.0pt (roughly 4.77 inches or 121.2 mm).
  • Multi-column journals: In a two-column IEEE format (IEEEtran), linewidth in regular paragraphs measures approximately 252.0pt (roughly 3.5 inches or 88.9 mm), matching the single-column target for publication charts.
  • Nested lists: Inside a first-level itemize environment, thelinewidth shrinks by leftmargin + rightmargin (typically reducing by 25pt to 30pt), ensuring nested boxes align flush with indented bullet items.

In PDF viewers, elements sized with linewidth align flush with the left and right margins of the text block. If an element extends past the right text boundary or overlaps an adjacent column, LaTeX records an overfull horizontal box error in the compilation log.

Troubleshooting

Authors encountering layout anomalies when manipulating line lengths can resolve common failure modes using the following diagnostic checks:

Overfull hbox warnings on side-by-side minipages

Symptom: Two minipages configured as {0.5linewidth} drop onto separate lines, accompanied by an Overfull hbox message in the console log.
Cause: LaTeX treats the carriage return between end{minipage} and begin{minipage} as an active whitespace character, which adds inter-word spacing (typically 3pt to 4pt). The total combined width exceeds 1.0linewidth.
Fix: Place a percent sign (%) immediately following the closing brace of the first minipage to suppress the trailing whitespace token, or use 0.49linewidth with an explicit hfill:

begin{minipage}{0.49linewidth}
  ...
end{minipage}% <-- Prevents unwanted space
hfill
begin{minipage}{0.49linewidth}
  ...
end{minipage}

Graphics bleeding into the adjacent column in IEEE or ACM templates

Symptom: An included graphic overlaps text in the second column or bleeds off the page edge.
Cause: The author specified width=textwidth inside a standard single-column floating environment (begin{figure}) within a two-column document. In two-column layout, textwidth equals the total page body width across both columns.
Fix: Switch the parameter to width=linewidth (or width=columnwidth). If the figure is intended to span across both columns, use the starred float environment begin{figure*} instead.

Unexpected zero width or clipping inside tabular environments

Symptom: Using linewidth inside a standard tabular column produces compilation errors or renders zero-width boxes.
Cause: Basic column specifiers (c, l, r) calculate width dynamically based on string contents; they do not establish a fixed paragraph box.
Fix: Wrap cell contents in a fixed-width paragraph column specifier (such as p{0.3linewidth}) or use the tabularx package with X column specifiers.

Free alternatives

While LaTeX remains the dominant open-source typesetting system for exact layout parameter control in research, authors and institutions evaluate alternative open scientific authoring tools:

Tool / System Layout Model & Width Control Primary Research Strengths Limitations License & Cost
LaTeX (pdfLaTeX, LuaLaTeX, XeLaTeX) Dynamic register system (linewidth, textwidth, columnwidth) with exact glue and box calculations. De facto standard for STEM publications; uncompromised mathematical typesetting; publisher template support. Steep learning curve; complex macro debugging; slower compilation times on large manuscripts. Free / Open Source (LPPL)
Typst Modern functional layout engine with relative percentage sizing (e.g. 100%, 1fr) and inspectable context lengths. Instantaneous compilation; modern clean scripting syntax; native package management. Evolving publisher adoption; older legacy journal templates still require LaTeX submission. Free / Open Source (Apache 2.0)
Quarto / Pandoc Markdown Computational document framework rendering Markdown to LaTeX, HTML, and Typst with dynamic figure layout attributes. Direct integration with Python, R, and Julia notebooks; multi-format publishing from single source. Fine-grained horizontal adjustments often require dropping down into raw LaTeX commands. Free / Open Source (GPL v2)
GNU Groff / Troff Low-level line-length register control (.ll) and macro packages (ms, me). Extremely lightweight; native Unix integration; fast pipeline compilation for technical documentation. Limited modern academic journal template availability; sparse bibliographic integration compared to BibTeX. Free / Open Source (GPL v3)

FAQ

What is the difference between linewidth and textwidth in LaTeX?

In LaTeX, textwidth represents the fixed width of the entire text body across the page, established in the document preamble. In contrast, linewidth represents the available width of lines in the current environment. While linewidth equals textwidth in standard single-column text, it dynamically reduces inside indented structures such as itemized lists, enumerated lists, and blockquotes.

Does linewidth change inside a minipage or nested list?

Yes. When entering a minipage or parbox, LaTeX resets linewidth to match the declared width of that box. In nested lists (such as itemize or enumerate), the LaTeX kernel automatically subtracts the sum of leftmargin and rightmargin from linewidth, ensuring child elements align with indented text.

How do I set an image width to exactly match linewidth in LaTeX?

Using the graphicx package, include your image with the key-value option width=linewidth inside the includegraphics macro: includegraphics[width=linewidth]{filename.pdf}. This ensures the graphic scales to 100% of the surrounding column or container without manual pixel or centimeter calculations.

How can I print the exact numerical value of linewidth in pt or cm?

To print the numerical value in points (pt), insert the native TeX instruction thelinewidth directly into your document text. To display the measurement in centimeters, millimeters, or inches, import the CTAN printlen package, declare your desired unit with uselengthunit{mm}, and output the length using printlength{linewidth}.

Why is my figure overflowing the column when using textwidth?

In two-column layouts (such as IEEE or ACM conference formats), textwidth spans the entire page width across both columns. Sizing a graphic with width=textwidth inside a standard single-column float forces it to overflow past the column boundary into adjacent text. Use width=linewidth or width=columnwidth for single-column figures, and reserve textwidth for two-column wide floats (figure*).

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about LaTeX Linewidth: How to Control Line Width and Sizing

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →