2

So here is the minimal-code:

\documentclass[a4paper, 12pt]{scrartcl}
\usepackage{tabularx}
\usepackage{chemfig}

\begin{tabularx}{\textwidth}{|X|c|c|X|} Name & Monomer & Polymermolekül & Einsatzbeispiel\ \hline Polyethen (PE)
& \chemfig{ H -[1]C (-[3]H) =C ( -[1]H) -[7]H } & \schemestart \chemleft[ \chemfig{ -C ( -[2]H) ( -[-2]H) -C ( -[2]H) ( -[-2]H) } \chemright]$_n$ \schemestop & Plastiktüten \ Polypropen (PP) & \chemfig{ H -C ( -[2]H) ( -[6]H) -C ( -[2]H) =C ( -[1]H) ( -[7]H) } & \schemestart \chemleft[ \chemfig{ -[0]C ( -[2]H) ( -[-2]H) -C ( -[2]{CH3}) -[0] } \chemright]$_n$ \schemestop & Flaschendeckel, Brotdosen \ Polyvenylchlorid (Pvc) & \chemfig{ H -[1]C ( -[3]H) =C ( -[1]Cl) -[7]H } & \schemestart \chemleft[ \chemfig{ -[0]C ( -[2]H) ( -[-2]H) -C ( -[6]H) ( -[2]{Cl}) -[0] } \chemright]$_n$ \schemestop & Rohrleitungen, Venylböden, Schallplatten \ Polyethafluorethen (PTFE) & \chemfig{ F -[1]C ( -[3]F) =C ( -[1]F) -[7]F }& \schemestart \chemleft[ \chemfig{ -C ( -[2]F) ( -[6]F) -C ( -[2]F) ( -[6]F) -[0] } \chemright]$_n$ \schemestop & Pfannenbeschichtung (Tephlon), Funktionskleidung (Gortex) \end{tabularx} \end{document}

That's how it looks like: How it currently looks like

As you can see the text isn't formatted in the table. Do you have an idea how I can fix this?

TornaxO7
  • 248
  • 1
  • 9
  • 3
    tex can not hyphenate the first word of a paragraph, put \hspace*{0pt} at the start of the X cells, but it may need help hyphenating the chemical terms with \- depending on which natural language patterns you are using, you may consider using a smaller font so it fits better – David Carlisle Sep 28 '20 at 08:34
  • Another possibility: a smaller value for \tabcolsep (default is 6pt) and a (small) scaling down of the molecules. – Bernard Sep 28 '20 at 08:55
  • @DavidCarlisle where should I put the \hspace*{0pt} command? – TornaxO7 Sep 28 '20 at 08:59
  • simplest is to insert it automatically>{\hspace*{0pt}}X in your tabular preamble – David Carlisle Sep 28 '20 at 09:00
  • you should also add German? option to babel to give tex a chance to hyphenate those words – David Carlisle Sep 28 '20 at 09:01
  • @DavidCarlisle Yeah!! It works now! Thank you very much! Could you please write that as an answer so I can tick it as "answered"? – TornaxO7 Sep 28 '20 at 09:12
  • And of course thank you @Bernard as well ^^ – TornaxO7 Sep 28 '20 at 09:12
  • @DavidCarlisle oh wait my second column is now a little bit moved to the top so the chemical structure isn't in one line with the text in the first column. – TornaxO7 Sep 28 '20 at 09:19
  • shoul dwork see https://tex.stackexchange.com/a/394081/1090 or https://tex.stackexchange.com/a/29095/1090 perhaps your word can not be hyphenated try adding \- somewhere – David Carlisle Sep 28 '20 at 09:30
  • 1
    Unrelated to the issue itself but you should take a look at \polymerdelim from chemfig in order tom correct the molecula formulas of your polymer molecules.(The brackes should be drawn through the outer bondes, not around them.) Please also take a look at the spelling of the words in your table. "venyl" should be "vinyl", "Tephlon" should be "Teflon" and so on. – leandriis Sep 28 '20 at 18:30

5 Answers5

4

TeX can not hyphenate the first word of a paragraph, put

\hspace*{0pt}

at the start of the X cells, for example you can add this to every X cell by using

>{\hspace*{0pt}}X 

in your tabular preamble

but it may need help hyphenating the chemical terms with \- depending on which natural language patterns you are using, You may need

\usepackage[german]{babel} %German?

As those words will not hyphenate well with the default English patterns.

You may also consider using a smaller font so it fits better

David Carlisle
  • 757,742
  • I know it is a basic question but what does \hspace*{0pt} actually do? – Diaa Sep 28 '20 at 19:14
  • it means there us white space before and after the the fist word (even though it is zero width) which is what tex needs to decide it s a word first considering hyphenation. If professor Knuth wasn't so eminent you'd say it was a simple out-by one error and fix the code to consider the first word by default (luatex does this) but as it is, it is a documented feature not a bug..... – David Carlisle Sep 28 '20 at 19:19
3

In addition to prefixing the X column type with a \hspace{0pt} directive to enable hyphenation -- see also David's answer -- you may want to create a list of acceptable hyphenation patterns, as the babel/ngerman combination tends not be informed all that well about how words such as "Polyvenylchlorid" and "Polyethafluorethen" might be hyphenated acceptably.

enter image description here

\documentclass[a4paper, 12pt]{scrartcl}
\usepackage[T1]{fontenc} % to list words with Umlauts in arg. of '\hyphenation'
\usepackage[ngerman]{babel}

\usepackage{tabularx,ragged2e} \newcolumntype{L}{>{\hspace{0pt}\RaggedRight}X} \renewcommand\tabularxcolumn[1]{m{#1}}

\usepackage{chemfig}

% Create a list of hyphenation exceptions: \hyphenation{plastik-tüten poly-venyl-chlorid poly-etha-fluor-ethen flaschen-deckel einsatz-beispiel venyl-boden venyl-böden schall-platten}

\begin{document} \begin{tabularx}{\textwidth}{|L|c|c|L|} Name & Monomer & Polymermolekül & Einsatzbeispiel\ \hline Polyethen (PE)
& \chemfig{ H -[1]C (-[3]H) =C ( -[1]H) -[7]H } & \schemestart \chemleft[ \chemfig{ -C ( -[2]H) ( -[-2]H) -C ( -[2]H) ( -[-2]H) } \chemright]$_n$ \schemestop & Plastiktüten \ Polypropen (PP) & \chemfig{ H -C ( -[2]H) ( -[6]H) -C ( -[2]H) =C ( -[1]H) ( -[7]H) } & \schemestart \chemleft[ \chemfig{ -[0]C ( -[2]H) ( -[-2]H) -C ( -[2]{CH3}) -[0] } \chemright]$_n$ \schemestop & Flaschendeckel, Brotdosen \ Polyvenylchlorid (Pvc) & \chemfig{ H -[1]C ( -[3]H) =C ( -[1]Cl) -[7]H } & \schemestart \chemleft[ \chemfig{ -[0]C ( -[2]H) ( -[-2]H) -C ( -[6]H) ( -[2]{Cl}) -[0] } \chemright]$_n$ \schemestop & Rohrleitungen, Venylböden, Schallplatten \ Polyethafluorethen (PTFE) & \chemfig{ F -[1]C ( -[3]F) =C ( -[1]F) -[7]F }& \schemestart \chemleft[ \chemfig{ -C ( -[2]F) ( -[6]F) -C ( -[2]F) ( -[6]F) -[0] } \chemright]$_n$ \schemestop & Pfannenbeschichtung (Tephlon), Funktionskleidung (Gortex) \end{tabularx} \end{document}

Mico
  • 506,678
3

A small variation of @Mico answer. Used are:

  • cellspace for adding a small vertial space around cells contents
  • djustbox for vertical centering of \chemfig formula

enter image description here

\documentclass[a4paper, 12pt]{scrartcl}
\usepackage[T1]{fontenc} % to list words with Umlauts in arg. of '\hyphenation'
\usepackage[ngerman]{babel}

\usepackage{ragged2e} \usepackage{cellspace, tabularx} \setlength\cellspacetoplimit{4pt} \setlength\cellspacebottomlimit{4pt} \newcolumntype{L}{>{\hspace{0pt}\RaggedRight}X}

\usepackage{chemfig} \usepackage{adjustbox}

% Create a list of hyphenation exceptions: \hyphenation{plastik-tüten poly-venyl-chlorid poly-etha-fluor-ethen flaschen-deckel einsatz-beispiel venyl-boden venyl-böden schall-platten}

\begin{document} { \renewcommand\tabularxcolumn[1]{m{#1}} \begin{tabularx}{\textwidth}{|L|c|Sc|L|} Name & Monomer & Polymermolekül & Einsatzbeispiel\ \hline Polyethen (PE) & \adjustbox{valign=c}{\chemfig{ H -[1]C (-[3]H) =C ( -[1]H) -[7]H} } & \schemestart \chemleft[ \chemfig{ -C ( -[2]H) ( -[-2]H) -C ( -[2]H) ( -[-2]H) } \chemright]$_n$ \schemestop & Plastiktüten \ Polypropen (PP) & \adjustbox{valign=c}{\chemfig{ H -C ( -[2]H) ( -[6]H) -C ( -[2]H) =C ( -[1]H) ( -[7]H)} } & \schemestart \chemleft[ \chemfig{ -[0]C ( -[2]H) ( -[-2]H) -C ( -[2]{CH3}) -[0] } \chemright]$_n$ \schemestop & Flaschendeckel, Brotdosen \ Polyvenylchlorid (Pvc) & \adjustbox{valign=c}{\chemfig{ H -[1]C ( -[3]H) =C ( -[1]Cl) -[7]H} } & \schemestart \chemleft[ \chemfig{ -[0]C ( -[2]H) ( -[-2]H) -C ( -[6]H) ( -[2]{Cl}) -[0] } \chemright]$_n$ \schemestop & Rohrleitungen, Venylböden, Schallplatten \ Polyethafluorethen (PTFE) & \adjustbox{valign=c}{\chemfig{ F -[1]C ( -[3]F) =C ( -[1]F) -[7]F} } & \schemestart \chemleft[ \chemfig{ -C ( -[2]F) ( -[6]F) -C ( -[2]F) ( -[6]F) -[0] } \chemright]$_n$ \schemestop & Pfannenbeschichtung (Tephlon), Funktionskleidung (Gortex) \end{tabularx} } \end{document}

Zarko
  • 296,517
  • First of all: Thank you for your help! I see that you are using |L|c|Sc|L| for each column. What they mean? I just could found c and X in the manual of tabularx – TornaxO7 Sep 28 '20 at 21:20
  • @TornaxO7, Scome fromcellspacepackage. It add defined vertical space in cells in the column which follows (Scis one column!).You should care, that ˛S is not used in document, which use siunitx. IN this case you should use C (default provided by siunitx package) or defined some other symbol, whic activate additions of vertical space by option [column=...], for example: \usepackage[column=O]{cellspace}. – Zarko Sep 28 '20 at 22:02
  • So if I want to get more information about the column options (like c, X or S) than I have to read the doc of siunitx? – TornaxO7 Sep 29 '20 at 17:18
  • @TornaxO7, reading the oackages' documentation is generally highly recommended. siunitx define only S columns, other column types are described in documentation for array package. Introduction text about writing tables is in https://en.wikibooks.org/wiki/LaTeX/Tables. – Zarko Sep 29 '20 at 17:26
  • Thank you for the tipps! ^^ – TornaxO7 Sep 29 '20 at 17:39
2

How about this other layout?

\documentclass[a4paper, 12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{tabularx}
\usepackage{chemfig}

\begin{document}

\setlength{\tabcolsep}{4pt} \setlength{\extrarowheight}{2pt} \renewcommand{\tabularxcolumn}[1]{m{#1}} \begin{tabularx}{\textwidth}{|l|c|c|X|} Name & Monomer & Polymermolekül & Einsatzbeispiel\ \hline \multicolumn{4}{|l|}{Polyethen (PE)} \[1ex] & \chemfig{ H -[1]C (-[3]H) =C ( -[1]H) -[7]H } & \schemestart \chemleft[ \chemfig{ -C ( -[2]H) ( -[-2]H) -C ( -[2]H) ( -[-2]H) } \chemright]$_n$ \schemestop & Plastiktüten \ \multicolumn{4}{|l|}{ Polypropen (PP)} \[1ex] & \chemfig{ H -C ( -[2]H) ( -[6]H) -C ( -[2]H) =C ( -[1]H) ( -[7]H) } & \schemestart \chemleft[ \chemfig{ -[0]C ( -[2]H) ( -[-2]H) -C ( -[2]{CH3}) -[0] } \chemright]$_n$ \schemestop & Flaschendeckel, Brotdosen \ \multicolumn{4}{|l|}{Polyvenylchlorid (Pvc)} \[1ex] & \chemfig{ H -[1]C ( -[3]H) =C ( -[1]Cl) -[7]H } & \schemestart \chemleft[ \chemfig{ -[0]C ( -[2]H) ( -[-2]H) -C ( -[6]H) ( -[2]{Cl}) -[0] } \chemright]$_n$ \schemestop & Rohrleitungen, Venylböden, Schallplatten \ \multicolumn{4}{|l|}{ Polyethafluorethen (PTFE)}\[1ex] & \chemfig{ F -[1]C ( -[3]F) =C ( -[1]F) -[7]F }& \schemestart \chemleft[ \chemfig{ -C ( -[2]F) ( -[6]F) -C ( -[2]F) ( -[6]F) -[0] } \chemright]$_n$ \schemestop & Pfannenbeschichtung (Tephlon), Funktionskleidung (Gortex) \end{tabularx}

\end{document}

enter image description here

Bernard
  • 271,350
1

Here are two more versions of your table. In both, I have corrected the chemical formulae of the polymer molecules using \polymerdelim from the chemfig package. With this command, the square brackets are correctly drawn through the outermost bonds, instead of around them. I have also corrected some of the typos in the compound names and in the application examples.

enter image description here

enter image description here

\documentclass[a4paper, 12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{tabularx}
\usepackage{chemfig}
\usepackage{adjustbox}
\usepackage{pdflscape}
\usepackage[column=0]{cellspace}
\usepackage{makecell}

\setlength\cellspacetoplimit{8pt} \setlength\cellspacebottomlimit{8pt}

\begin{document} \begin{landscape} \noindent \begin{tabularx}{\linewidth}{|0l|0c|0c|>{\raggedright\arraybackslash}X|} Name & Monomer & Polymermolekül & Einsatzbeispiel\ \hline & & & \ \makecell[cl]{Polyethen\ (PE)} & \adjustbox{valign=c}{\chemfig{ H -[1]C (-[3]H) =C ( -[1]H) -[7]H }} & \schemestart \chemfig{ -[@{upleft,0.5},1]C ( -[2]H) ( -[-2]H) -C ( -[2]H) ( -[-2]H) -[@{upright,0.5},1] } \polymerdelim[delimiters ={[]}, height = 45pt, depth = 40pt, indice = n]{upleft}{upright} \schemestop & Plastiktüten \ \makecell[cl]{Polypropen\ (PP)} & \adjustbox{valign=c}{\chemfig{ H -C ( -[2]H) ( -[6]H) -C ( -[2]H) =C ( -[1]H) ( -[7]H) }} & \schemestart \chemfig{ -[@{upleft,0.5},1]C ( -[2]H) ( -[-2]H) -C ( -[2]{CH_3}) -[@{right,0.5},1] } \polymerdelim[delimiters ={[]}, height = 45pt, depth = 40pt, indice = n]{upleft}{upright} \schemestop & Flaschendeckel, Brotdosen \ \makecell[cl]{Polyvinylchlorid\ (PVC)} & \adjustbox{valign=c}{\chemfig{ H -[1]C ( -[3]H) =C ( -[1]Cl) -[7]H }} & \schemestart \chemfig{ -[@{upleft,0.5},1]C ( -[2]H) ( -[-2]H) -C ( -[6]H) ( -[2]{Cl}) -[@{right,0.5},1] } \polymerdelim[delimiters ={[]}, height = 45pt, depth = 40pt, indice = n]{upleft}{upright} \schemestop & Rohrleitungen, Vinylböden, Schallplatten \ \makecell[cl]{Polytetrafluorethen\ (PTFE)} & \adjustbox{valign=c}{\chemfig{ F -[1]C ( -[3]F) =C ( -[1]F) -[7]F }}& \schemestart \chemfig{ -[@{upleft,0.5},1]C ( -[2]F) ( -[6]F) -C ( -[2]F) ( -[6]F) -[@{right,0.5},1] } \polymerdelim[delimiters ={[]}, height = 45pt, depth = 40pt, indice = n]{upleft}{upright} \schemestop & Pfannenbeschichtung (Teflon), Funktionskleidung (Goretex) \end{tabularx} \end{landscape}

\setlength\cellspacetoplimit{15pt} \setlength\cellspacebottomlimit{15pt} \renewcommand{\tabularxcolumn}[1]{m{#1}} \noindent \begin{tabularx}{\linewidth}{|0l|0c|0c|>{\raggedright\arraybackslash\hspace{0pt}}X|} Name & Monomer & Polymermolekül & Einsatzbeispiel\ \hline \makecell[cl]{Polyethen\ (PE)} & \adjustbox{valign=c}{\chemfig{ H -[1]C (-[3]H) =C ( -[1]H) -[7]H }} & \schemestart \chemfig{ -[@{upleft,0.5},1]C ( -[2]H) ( -[-2]H) -C ( -[2]H) ( -[-2]H) -[@{upright,0.5},1] } \polymerdelim[delimiters ={[]}, height = 45pt, depth = 40pt, indice = n]{upleft}{upright} \schemestop & Plastiktüten \ \makecell[cl]{Polypropen\ (PP)} & \adjustbox{valign=c}{\chemfig{ H -C ( -[2]H) ( -[6]H) -C ( -[2]H) =C ( -[1]H) ( -[7]H) }} & \schemestart \chemfig{ -[@{upleft,0.5},1]C ( -[2]H) ( -[-2]H) -C ( -[2]{CH_3}) -[@{right,0.5},1] } \polymerdelim[delimiters ={[]}, height = 45pt, depth = 40pt, indice = n]{upleft}{upright} \schemestop & Flaschendeckel, Brotdosen \ \makecell[cl]{Polyvinyl-\chlorid\ (PVC)} & \adjustbox{valign=c}{\chemfig{ H -[1]C ( -[3]H) =C ( -[1]Cl) -[7]H }} & \schemestart \chemfig{ -[@{upleft,0.5},1]C ( -[2]H) ( -[-2]H) -C ( -[6]H) ( -[2]{Cl}) -[@{right,0.5},1] } \polymerdelim[delimiters ={[]}, height = 45pt, depth = 40pt, indice = n]{upleft}{upright} \schemestop & Rohrleitungen, Vinylböden, Schallplatten \ \makecell[cl]{Polytetra-\fluorethen\ (PTFE)} & \adjustbox{valign=c}{\chemfig{ F -[1]C ( -[3]F) =C ( -[1]F) -[7]F }}& \schemestart \chemfig{ -[@{upleft,0.5},1]C ( -[2]F) ( -[6]F) -C ( -[2]F) ( -[6]F) -[@{right,0.5},1] } \polymerdelim[delimiters ={[]}, height = 45pt, depth = 40pt, indice = n]{upleft}{upright} \schemestop & Pfannenbeschichtung (Teflon), Funktionskleidung (Goretex) \end{tabularx}

\end{document}

leandriis
  • 62,593
  • Dayum. That's looking delicious! Thank you very much! You even added some little details as you mentioned with the brackets. It's looking now like (no, even better) how my teacher wrote it on the blackboard. Thanks :) – TornaxO7 Sep 28 '20 at 21:16