4

I have a problem with forcing my table to the same width as the text. I export the csv (Excel) file to Latex using this approach, see code. Changing text-size in Excel works to a curtain "level", but the text want change more then what i get now, see pictures. I have tried a lot, but nothing works. Either i get errors or get the same width as now. Is there a simple way, notation, without changing the whole code.

\usepackage{pgfplotstable}

\documentclass[a4paper, 12pt]{book}

\begin{table}[H]
\begin{center}
    \caption{Maximum shear force}
    \pgfplotstabletypeset[
        col sep=semicolon,
        columns/Element/.style={string type},
        columns/Joint/.style={string type},
        columns/M11/.style={string type},
        columns/M22/.style={string type},
        columns/M12/.style={string type},
        columns/MMax/.style={string type},
        columns/MMin/.style={string type},
        columns/V13/.style={string type},
        columns/V23/.style={string type},
        columns/VMax/.style={string type},          
        every head row/.style={
            before row=\toprule,
            after row=\midrule
        },
        every last row/.style={after row=\bottomrule}
    ]{Mmax.csv}
    \label{tab:SlabMMax}
\end{center}

\end{table}

enter image description here

1

You can use the resizebox command from the graphicx package:

    \resizebox{\linewidth}{!}{%
    \pgfplotstabletypeset[

     ...
     }

Here's complete code:

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage[showframe=false,right=7cm]{geometry}
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\begin{table}[!h]
  \centering
    \caption{Maximum shear force}
    \resizebox{\linewidth}{!}{%
    \pgfplotstabletypeset[
        col sep=semicolon,
        row sep=crcr,
        columns/Element/.style={string type},
        columns/Joint/.style={string type},
        columns/M11/.style={string type},
        columns/M22/.style={string type},
        columns/M12/.style={string type},
        columns/MMax/.style={string type},
        columns/MMin/.style={string type},
        columns/V13/.style={string type},
        columns/V23/.style={string type},
        columns/VMax/.style={string type},          
        every head row/.style={%
            before row=\toprule,%
            after row=\midrule%
        },%
        every last row/.style={after row=\bottomrule}
    ]{%
Element; Joint;M11;M22;M12;MMax;MMin;V13;V23;VMax\\
1;222;333;444;555;666;7;8;9;1010\\
}
}
\end{table}

\end{document}
  • Hi! Thanks for this. Though, it was not exactly what i wanted. By this the excel document is unnecessary?! This due to that the table is remade in LaTEX?! I "solved" the problem by making the table smaller (omit some data)... – mwasberg Apr 26 '16 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.