Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
3_composition:tableaux:colonnes:faire_varier_la_largeur_de_colonnes [2018/05/24 10:39] joseph.wright |
3_composition:tableaux:colonnes:faire_varier_la_largeur_de_colonnes [2018/12/04 00:34] jejust |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | --- | + | ====== Variable-width columns in tables ====== |
- | section: How do I do…? | + | |
- | subsection: Tables, figures and diagrams | + | |
- | date: 2014-06-10 | + | |
- | --- | + | |
- | # Variable-width columns in tables | ||
This is a slightly different take on the problem addressed in | This is a slightly different take on the problem addressed in | ||
- | ''[fixed-width tables](FAQ-fixwidtab.md)'' — here we have | + | "[[FAQ-fixwidtab|fixed-width tables]]" --- here we have |
a column whose size we can't absolutely predict when we design the | a column whose size we can't absolutely predict when we design the | ||
document. | document. | ||
- | While the basic techniques (the [`tabularx`](https://ctan.org/pkg/tabularx), [`tabulary`](https://ctan.org/pkg/tabulary) | + | While the basic techniques (the [[ctanpkg>tabularx|tabularx]], [[ctanpkg>tabulary|tabulary]] |
- | and [`ltxtable`](https://ctan.org/pkg/ltxtable) packages) are the same for this problem as for the | + | and [[ctanpkg>ltxtable|ltxtable]] packages) are the same for this problem as for the |
- | fixed-width _table_ problem, there's one extra tool that we can | + | fixed-width //table// problem, there's one extra tool that we can |
call to our aid, which may be preferable in some situations. | call to our aid, which may be preferable in some situations. | ||
Ligne 21: | Ligne 16: | ||
the column may end up pretty narrow in every row of the table, or it | the column may end up pretty narrow in every row of the table, or it | ||
may be wide enough that the table would run over the edge of the page; | may be wide enough that the table would run over the edge of the page; | ||
- | however, we don't want to make the column as wide as possible ''just | + | however, we don't want to make the column as wide as possible "just |
- | in case'', by defining a fixed size for the table. We would like the | + | in case", by defining a fixed size for the table. We would like the |
column to be as small as possible, but have the possibility to spread | column to be as small as possible, but have the possibility to spread | ||
to a maximum width and (if even that width is exceeded) turn into a | to a maximum width and (if even that width is exceeded) turn into a | ||
- | `p`-style column. | + | ''p''-style column. |
- | The [`varwidth`](https://ctan.org/pkg/varwidth) package, discussed in | + | The [[ctanpkg>varwidth|varwidth]] package, discussed in |
- | ''[automatic sizing of minipages](FAQ-varwidth.md)'', provides | + | "[[FAQ-varwidth|automatic sizing of minipages]]", provides |
- | a solution. If you load it together with the LaTeX ''required'' | + | a solution. If you load it together with the LaTeX "required" |
- | [`array`](https://ctan.org/pkg/array) package, i.e.: | + | [[ctanpkg>array|array]] package, i.e.: |
- | ```latex | + | |
+ | <code latex> | ||
\usepackage{array} | \usepackage{array} | ||
\usepackage{varwidth} | \usepackage{varwidth} | ||
- | ``` | + | </code> |
- | [`varwidth`](https://ctan.org/pkg/varwidth) defines a new column-type `V`, which you | + | [[ctanpkg>varwidth|varwidth]] defines a new column-type ''V'', which you |
can use as follows: | can use as follows: | ||
- | ```latex | + | |
+ | <code latex> | ||
\begin{tabular}{l V{3.5cm} r} | \begin{tabular}{l V{3.5cm} r} | ||
foo & blah & bar \\ | foo & blah & bar \\ | ||
foo & blah blah & bar \\ | foo & blah blah & bar \\ | ||
\end{tabular} | \end{tabular} | ||
- | ``` | + | </code> |
when the second column ends up less than 3.5cm wide; | when the second column ends up less than 3.5cm wide; | ||
or you can use it as follows: | or you can use it as follows: | ||
- | ```latex | + | |
+ | <code latex> | ||
\begin{tabular}{l V{3.5cm} r} | \begin{tabular}{l V{3.5cm} r} | ||
foo & blah & bar \\ | foo & blah & bar \\ | ||
Ligne 52: | Ligne 50: | ||
& bar \\ | & bar \\ | ||
\end{tabular} | \end{tabular} | ||
- | ``` | + | </code> |
where the second column will end up noticeably wider, and will wrap to | where the second column will end up noticeably wider, and will wrap to | ||
a second line in the third row. | a second line in the third row. | ||
+ | |||
+ | ----- | ||
+ | |||
+ | //Source:// [[faquk>FAQ-varwidcol|Variable-width columns in tables]] | ||
+ | |||
+ | {{htmlmetatags>metatag-keywords=(LaTeX,figures,floats,tables) | ||
+ | metatag-og:title=(Variable-width columns in tables) | ||
+ | metatag-og:site_name=(FAQ LaTeX francophone) | ||
+ | }} | ||