Erstellen einer tabellarischen Tabelle

Erstellen einer tabellarischen Tabelle

Ich möchte eine tabellarische Tabelle wie diese entwickeln. Bildbeschreibung hier eingeben

Wenn ich jedoch den Referenzcode von verwendehttps://www.overleaf.com/learn/latex/Tables#Creating_a_simple_table_in_LaTeX, mit Code:

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{0.8\textwidth} { 
  | >{\raggedright\arraybackslash}X 
  | >{\centering\arraybackslash}X 
  | >{\raggedleft\arraybackslash}X | }
 \hline
 Place/Transition & Explanation & Time  \\
 \hline
 T_1 and T_(2(n+1))  & Robot operation which relates to loadlocks. Transition T_1indicates that wafer unloading from the loadlocks and T_(2(n+1)) means that the robot loads the wafer to the loadlocks. & w \\
\hline
 item 31  & item 32  & item 33 \\

\hline
\end{tabularx}
\end{document}

Das Ergebnis ist wie folgt.

Bildbeschreibung hier eingeben

Hat vielleicht jemand eine andere Referenz zum Erstellen einer tabellarischen Tabelle, die ich möchte?

Wenn ich \begin{tabularx}{0.8\textwidth} durch \noindent\begin{tabularx}{\linewidth} ersetze, ist hier das Ergebnis:

Bildbeschreibung hier eingeben Vielen Dank im Voraus.

Antwort1

Das Problem ist, wie in den Kommentaren erwähnt, dass Sie die notwendige Syntax für den Mathematikmodus weglassen. Aus diesem Grund liest TeX irgendwann ein a, _was nur im Mathematikmodus ein gültiges Zeichen ist. Daher wechselt es automatisch in den Mathematikmodus, aber da es nicht weiß, wo der Mathematikmodus enden soll, setzt es den Satz im Mathematikmodus fort, was zu dieser seltsamen Ausgabe führt.

Dieses Problem lässt sich ganz einfach lösen, indem man die korrekte Syntax für den Mathematikmodus verwendet. Da man in den Spalten eins und drei keine Absätze braucht, könnte man auch zu einer anderen Spaltendefinition wechseln:

\documentclass{article}
\usepackage{tabularx}

\begin{document}
\begin{tabularx}{0.8\textwidth} { |
  l |
  >{\raggedright\arraybackslash}X |
  c |
}
  \hline
  Place/Transition & Explanation & Time  \\
  \hline
  $T_1$ and $T_{2(n+1)}$  & Robot operation which relates to loadlocks. Transition $T_1$ indicates that wafer unloading from the loadlocks and $T_{2(n+1)}$ means that the robot loads the wafer to the loadlocks. & w \\
  \hline
  item 31 & item 32 & item 33 \\
  \hline
\end{tabularx}
\end{document}

Bildbeschreibung hier eingeben

Mithilfe des booktabsPakets kann eine alternative Lösung erstellt werden, mit der Sie die Anzahl der Grenzen zwischen Zellen reduzieren können:

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}
\renewcommand{\arraystretch}{1.25}
\begin{tabularx}{0.8\textwidth} { 
  l 
  >{\raggedright\arraybackslash}X 
  c 
}
  \toprule
  Place/Transition & Explanation & Time  \\
  \midrule
  $T_1$ and $T_{2(n+1)}$  & Robot operation which relates to loadlocks. Transition $T_1$ indicates that wafer unloading from the loadlocks and $T_{2(n+1)}$ means that the robot loads the wafer to the loadlocks. & w \\
  item 31 & item 32 & item 33 \\
  \bottomrule
\end{tabularx}
\end{document}

Bildbeschreibung hier eingeben


0.8\textwidthBeachten Sie, dass Sie möglicherweise durch ersetzen möchten, \linewidthwenn Sie die Tabelle in einem zweispaltigen Layout auf die Breite einer Textspalte erweitern möchten:

\documentclass[journal]{IEEEtran}
\usepackage{lipsum}
\usepackage{tabularx}

\begin{document}

\lipsum[1]

\noindent%
\begin{tabularx}{\linewidth} { |
  l |
  >{\raggedright\arraybackslash}X |
  c |
}
  \hline
  Place/Transition & Explanation & Time  \\
  \hline
  $T_1$ and $T_{2(n+1)}$  & Robot operation which relates to loadlocks. Transition $T_1$ indicates that wafer unloading from the loadlocks and $T_{2(n+1)}$ means that the robot loads the wafer to the loadlocks. & w \\
  \hline
  item 31 & item 32 & item 33 \\
  \hline
\end{tabularx}

\newpage

Right column

\end{document}

Bildbeschreibung hier eingeben

Antwort2

Hier ist eine Idee, die die zweite Tabelle ergänzt@JasperHabichts Antwort: Entfernen Sie die Leerzeichen an beiden Enden und lassen Sie Zeilenumbrüche in Spalte 1 zu.

Bildbeschreibung hier eingeben

\documentclass{article}
\usepackage{tabularx} % for 'tabularx' env. and 'X' column type
\usepackage{booktabs} % for well-spaced horizontal rules
\usepackage{ragged2e} % for '\RaggedRight' macro
\newlength\mylen

\begin{document}

\begin{center}
\settowidth\mylen{Transition} % target width of column 1
\begin{tabularx}{0.8\textwidth} {@{} 
     >{\RaggedRight}p{\mylen} >{\RaggedRight}X c @{}}
 \toprule
 Place\slash Transition & Explanation & Time  \\
 \midrule
 $T_1$ and $T_{2(n+1)}$  & 
 Robot operation which relates to loadlocks. Transition $T_1$ indicates that wafer unloading from the loadlocks, and $T_{2(n+1)}$ means that the robot loads the wafer to the loadlocks. & 
 $w$ \\
 \addlinespace
 item 31 & item 32 & item 33 \\
 \bottomrule
\end{tabularx}
\end{center}
\end{document}

verwandte Informationen