Hot answers tagged

110 votes
Accepted

My table doesn't fit; what are my options?

Let's first identify what we're referring to when we use the term "table". The typical table environment is a float, and can contain anything: a paragraph of text, an image, or even a ...
Werner's user avatar
  • 589k
34 votes
Accepted

Setting table-width exactly to linewidth

I think you have two good choices and a (likely) dreadful choice: Use a tabular* environment, Use a tabularx environment (or its close cousin, tabulary) Use the basic tabular environment and scale ...
Mico's user avatar
  • 478k
32 votes
Accepted

Draw TikZ circles with a specific outer radius

in tikz any coordinate of any path command is determined for the infinitely thin lines. the real lines lie over them so that their centers matches. line width of real lines is accessible with length \...
Zarko's user avatar
  • 283k
31 votes
Accepted

Changing width of table lines

Update Use \arrayrulewidth from the preamble and place it before the desired table using a group to keep the change to \arrayrulewidth local: \documentclass[11pt]{article} \usepackage{array} \begin{...
Gonzalo Medina's user avatar
31 votes
Accepted

In LaTeX, make a box with the width of another text

Something like this? \documentclass{article} \newlength\stextwidth \newcommand\makesamewidth[3][c]{% \settowidth{\stextwidth}{#2}% \makebox[\stextwidth][#1]{#3}% } \begin{document} \fbox{\...
cfr's user avatar
  • 186k
21 votes

How to know the column width of a two column article?

The column width is stored in the length \columnwidth. It's value can be turned into a text representation using \the\columnwidth. Either use this inside \message{...} to print it to the LaTeX ...
Martin Scharrer's user avatar
18 votes

In LaTeX, make a box with the width of another text

calc provides \widthof{<stuff>}: \documentclass{article} \usepackage{calc} \setlength{\parindent}{0pt}% Just for this example \begin{document} Here is some text that is lengthy.\par \makebox[\...
Werner's user avatar
  • 589k
18 votes
Accepted

How to take figure width=\linewidth OR height=\pageheight?

Just let the graphicx package have its way: \documentclass{article} \usepackage{graphicx} \usepackage[showframe]{geometry} %just to visualise the boarder \begin{document} \noindent\includegraphics[...
samcarter_is_at_topanswers.xyz's user avatar
16 votes

Width of the caption of a figure

Instead of using a predetermined width, one can measure the width using a savebox and put the caption inside a minipage. \documentclass{article} \usepackage{graphicx} \usepackage{blindtext} \begin{...
John Kormylo's user avatar
  • 75.3k
15 votes
Accepted

How to make underbrace label text wrap at brace width?

If you want to change the behaviour of \underbrace globally you could say \documentclass{article} \usepackage{amsmath} \makeatletter \let\ams@underbrace=\underbrace \def\underbrace#1_#2{% \setbox0=...
Ruben's user avatar
  • 13.3k
14 votes
Accepted

Why is listings' frame width a little larger then \textwidth?

The frame is put outside of the listings. Therefore xleftmargin and xrightmargin can be used to leave room for the frame. The default for framesep is 3pt and the default for framerule is 0.4pt. ...
Heiko Oberdiek's user avatar
13 votes
Accepted

how to resize the width of subcaption

Two possible ways to choose from. The first is making the whole subfigure a bit smaller, which will also make the figure a little bit smaller. If that is undesired, just make the caption width a bit ...
Johannes_B's user avatar
13 votes

Fraction of \textwidth as image width

Informally, length calculation are done using factor multiplication as there is no division notation. Since any division can be represented as some multiplication, this shouldn't be a problem. So, .5\...
Werner's user avatar
  • 589k
11 votes

How to create fixed width table columns with text raggedright/centered/raggedleft?

I found a very different technique that also works: With the package ragged2e you can issue the command \RaggedRight outside the tabular environment and get ragged right inside p- or m-columns of a ...
Sir Cornflakes's user avatar
11 votes

How to make underbrace label text wrap at brace width?

In this code I define a \parunderbrace command, with two arguments, which adjusts automatically to the width of the formula: \documentclass{article} \usepackage{mathtools} \usepackage{ragged2e} \...
Bernard's user avatar
  • 269k
11 votes
Accepted

How to have a node's width match another's height?

You can use fit library to compute node's height. But with fitting nodes, it's better to add its contents with the label option. Following code defines a barstyle style with two arguments, the first ...
Ignasi's user avatar
  • 134k
11 votes
Accepted

How to make \cdot operator same width as / (division slash) operator and vice versa

You can use a \makebox to create a box as wide as the slash: Code: \documentclass{article} \usepackage{amsmath} \usepackage{calc} \newcommand*{\mycdot}{\makebox[\widthof{/}]{$\cdot$}} \newcommand*{\...
Peter Grill's user avatar
11 votes
Accepted

TikZ: How to set width of complicated TikZ-image to \textwidth?

If your image is wider than \textwidth you'll have to work on it to adjust it to desired width. This solution won't change any image dimension (width, height, font size) unless you do it. Another ...
Ignasi's user avatar
  • 134k
11 votes
Accepted

LaTeX - how to detect scale of \includegraphics

If you specify both height and width keys, and specify keepaspectratio then the values are taken as upper bounds and the image is scaled so that both height and width fit within the specified areas, ...
David Carlisle's user avatar
11 votes

Auto width tcolorbox around equation

From this excellent macro of Thomas F. Sturm: ....fit the width...., here there is my adapt answer: \documentclass[11pt]{article} \usepackage[many]{tcolorbox} \tcbset{longtitle/.style={% title={#1},...
Sebastiano's user avatar
  • 51.3k
11 votes
Accepted

How to calculate the total width of a (tabularray) table and pass this length to other packages such tikz or tcolorbox?

You could use the \settowidth macro to measure the width of your table. To avoid having to code the table twice, you could use a savebox and use it once to typeset your table and another time to ...
samcarter_is_at_topanswers.xyz's user avatar
10 votes

Table exceeds the page width

The table is much too wide for a normal portrait page. Therefore the following example rotates it via environment sidewaystable of package rotating. The width of the table is still too large, ...
Heiko Oberdiek's user avatar
10 votes
Accepted

tabularx with different column widths

I suppose you want the m column type width should be 40 % of the b type width, and the s type width half the m type width. The way you calculated the coefficients is not correct: the sum of the ...
Bernard's user avatar
  • 269k
10 votes
Accepted

What unit of measurement is \widthof using

When you do \documentclass[11pt]{article} \newlength{\mylen} \newcounter{a} \begin{document} \settowidth{\mylen}{asdasd} \the\mylen \setlength{\mylen}{\widthof{asdasd}} \the\mylen \end{...
egreg's user avatar
  • 1.1m
10 votes
Accepted

Auto width tcolorbox around equation

A different approach by defining a new key autowidth title that lets the minimum text width to be equal to the the title length \documentclass[11pt]{article} \usepackage[many]{tcolorbox} \pgfkeysdef{...
Hafid Boukhoulda's user avatar
9 votes
Accepted

How to do \widthof with a symbol

You could use \widthof{$\equiv$} but there's a slicker way with mathtools: \documentclass{article} \usepackage{amsmath,mathtools} \begin{document} \begin{align*} c_s &\equiv b_s^2\\ &\...
egreg's user avatar
  • 1.1m

Only top scored, non community-wiki answers of a minimum length are eligible