1

I have created a table with tabularx environment inside of LaTeX.

However, my problem is that if I try to make it larger than \textwidth, the tabularx is not centered anymore. What I need is a centered table with a horizontal length that equals the width of the page. However, my aim is to not to increase the separation between words to do that. I simply aim to write more words horizontally.

Below is my code. I had to take out the actual sentences. How can I do this?

\begin{table}[H]
    \centering\scalebox{0.8}{
    \begin{tabularx}{\textwidth}{X X}
\hline
        \textbf{Restrictions} & \textbf{Future Suggestion} \\ 
\hline
        1. dummy text & 1. dummy text    \\
        2. dummy text & 2. dummy text \\ 
        3. dummy text.& 3. dummy text \\
        4. dummy text & 4. dummy text \\
        5. dummy text & 5. dummytext   \\ 
    \end{tabularx}}
\end{table}
epR8GaYuh
  • 2,432
  • 1
    Welcome to TeX.SE! – Mensch Jan 25 '23 at 19:18
  • 2
    Welcome to TeX.SE! If you like to have table wider than \textwidth, you need to increase\textwidth inside float. For example by use of the changepage package. BTW, Avoid to use H placement of floats (using it, it not float anymore). – Zarko Jan 25 '23 at 19:19
  • Do not use svalebox but a – Fran Jan 25 '23 at 19:28
  • @Zarko, can you give a short example of how I can use changepage? – Electricity Jan 25 '23 at 19:36
  • 2
    Never scale a table as this produce inconsistent sizes of fonts an rules, just add a standard smaller font as \footnotesize. On the other hand, if the column contents are unven, using tabulary instead of tabularx (e.g. \begin{tabulary}{\textwidth}{RLCJ} could help to fit a big table). – Fran Jan 25 '23 at 19:37
  • 1
    Search this site for changepage. Also, the packet documentation well describe its use. For writing an example you need first extend your code fragment to complete small document, which show your problem. Some exampšle you can find in https://tex.stackexchange.com/questions/672788/, https://tex.stackexchange.com/questions/478496/, etc. – Zarko Jan 25 '23 at 19:52

1 Answers1

0

From your code fragment follows, that your table width is smaller than \textwidth, but in text you say that it is bigger. It would be more clear, what is your problem, if you would extend this code fragment to complete small document, which we can test it as it is.

So, as I mentioned in my comment, one of possible solutions is to use changepage package:


\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document

\usepackage[strict]{changepage} \usepackage{tabularx}

\begin{document} \lipsum[66] \begin{table}[ht] \begin{adjustwidth}{-4em}{-4em} \begin{tabularx}{\linewidth}{X X} % instead of \textwidth is used \linewidth! \hline \textbf{Restrictions} & \textbf{Future Suggestion} \ \hline 1. dummy text & 1. dummy text \ 2. dummy text & 2. dummy text \ 3. dummy text.& 3. dummy text \ 4. dummy text & 4. dummy text \ 5. dummy text & 5. dummytext \ \hline \end{tabularx} \end{adjustwidth} \end{table}

\lipsum[11] \end{document}

enter image description here

Is this what you after?

Zarko
  • 296,517