2

I have a document that is split into two columns of different width. In one of the two columns, I would like to add a table that is large exactly as the width of that column. Is there an automatic way to set the table width exactly as the column width where it appears?

In the following example I use paracol to split the document into two columns. In particular, I set the width of the left column as \columnratio{0.6}. Now, instead of writing \begin{tabularx}{0.4\textwidth}{|X|X|X|} for the width of the table in the right column, is there an automatic way (like a way to assign the variable "width") to the table? Something like \begin{tabularx}{{1-\columnratio{0.6}}\textwidth}{|X|X|X|}?

\documentclass{article} \usepackage[a4paper,margin=0.1cm]{geometry} \usepackage{paracol} \usepackage{lipsum} \usepackage{tabularx} \begin{document} \columnratio{0.6} \begin{paracol}{2} \lipsum[1] \switchcolumn \lipsum[1] \\ \begin{tabularx}{0.395\textwidth}{|X|X|X|} \hline item 11 & item 12 & item 13 \\ \hline item 21 & item 22 & item 23 \\ \hline \end{tabularx} \end{paracol} \end{document} 

enter image description here

8
  • 1
    Did you try \begin{tabularx}{\columnwidth}{|X|X|X|}? Commented Mar 7, 2024 at 14:45
  • Issue solved, thanks a lot! If you put it in an Answer, I accept it :-) Thanks a lot! Commented Mar 7, 2024 at 14:48
  • 1
    Please see the answer I've posted in the meantime (which I wrote before seeing @samcarter_is_at_topanswers.xyz's comment). Commented Mar 7, 2024 at 14:49
  • 1
    @Mico Nice solution :P Commented Mar 7, 2024 at 14:51
  • 2
    @Ommo No need to delete your question. Adding a duplicate just means that future users with the same problem will find additional reading material about the topic. Commented Mar 7, 2024 at 14:57

1 Answer 1

2

I suggest you change 0.395\textwidth to \columnwidth. (\linewidth works too.)

enter image description here

\documentclass{article} \usepackage[a4paper,margin=1mm]{geometry} \usepackage{paracol,lipsum,tabularx} \begin{document} \columnratio{0.6} \begin{paracol}{2} \lipsum[1] \switchcolumn \lipsum[1] \noindent \begin{tabularx}{\columnwidth}{|X|X|X|} \hline item 11 & item 12 & item 13 \\ \hline item 21 & item 22 & item 23 \\ \hline \end{tabularx} \end{paracol} \end{document} 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.