0

so I'm trying to create the following table:

\begin{tabular}{*{5}{c}}
    \toprule
    \parbox{2cm}{Stringer/Web} & \parbox{2cm}{Area of Stringer [$m^2$]} &
    \parbox{2cm}{Bending Stress $\sigma$ [$MPa$]} &
    \parbox{2cm}{Shear Flow due to Bending $q_B$ [$N/m$]} & 
    \parbox{2cm}{Shear Stress $\tau$ [$MPa$]}
\end{tabular}

However, the result looks terrible with the line breaks happening all over the place and the resulting text looks atrocious. Please help?

MWE:

\documentclass[a4paper]{article}
\usepackage{booktabs}
\usepackage{tabu}
\usepackage{multirow}
\usepackage{amsmath}
\numberwithin{equation}{section}
\usepackage{amsfonts}
\begin{document}
\begin{tabular}{*{5}{c}}
    \toprule
    \parbox{2cm}{Stringer/Web} & \parbox{2cm}{Area of Stringer [$m^2$]} &
    \parbox{2cm}{Bending Stress $\sigma$ [$MPa$]} &
    \parbox{2cm}{Shear Flow due to Bending $q_B$ [$N/m$]} & 
    \parbox{2cm}{Shear Stress $\tau$ [$MPa$]}
\end{tabular}
\end{document}
  • Welcome to TeX.SX! Please make your example a compilable MWE. – TeXnician Apr 8 '17 at 11:24
  • Also, please include an example of what you think is atrocious… – Moriambar Apr 8 '17 at 11:26
  • How do I do that? What is MWE? Also how can I attach a picture here, then I'll show you what I mean by atrocious – Hrms Apr 8 '17 at 11:30
  • Try \raggedright inside the parboxes. Though i do'nt know why you are using them in the first place. – Johannes_B Apr 8 '17 at 11:32
  • 1
    ! LaTeX Error: Missing \begin{document}. – David Carlisle Apr 8 '17 at 11:44
1

Doing the units with siunitx and having a tabular that matches the textwidth.

\documentclass{article}
\usepackage{showframe}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{siunitx}
\renewcommand{\tabularxcolumn}[1]{>{\raggedright}m{#1}}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{lXXXX}
    \toprule
    Stringer/Web & 
    Area of Stringer in \si{\meter\squared} &
    Bending Stress $\sigma$ in \si{\mega\pascal} &
    Shear Flow due to Bending $q_B$ in \si{\newton\per\meter} & 
    Shear Stress $\tau$ in \si{\mega\pascal} 
\end{tabularx}
\end{document}
  • When I run this code I get: File `xparse.sty' not found. \ProvidesExplPackage – Hrms Apr 8 '17 at 11:50
  • That means you have an incomplete and maybe outdated LaTeX installation. – Johannes_B Apr 8 '17 at 11:52
  • I have the newest MikTex, which I updated just before I started working – Hrms Apr 8 '17 at 11:53
  • @Hrms Basic MikTeX or the complete install? – Johannes_B Apr 8 '17 at 11:53
  • Basic. I just added \usepackage{xparse} and now it works! Looks a lot better, thank you. Can you explain the code to me, so I can use it properly? I'm confused about \renewcommand{\tabularxcolumn}[1]{>{\raggedright}m{#1}} – Hrms Apr 8 '17 at 11:55

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.