表形式のテーブルを作成する

表形式のテーブルを作成する

このような表形式のテーブルを開発したいと思います。 ここに画像の説明を入力してください

しかし、私が参照コードを使用すると、https://www.overleaf.com/learn/latex/Tables#LaTeX で簡単なテーブルを作成する、コード:

\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}

結果は以下のようになります。

ここに画像の説明を入力してください

おそらく、私が望む表形式のテーブルを作成するための他の参考資料をお持ちの方はいらっしゃいますか?

\begin{tabularx}{0.8\textwidth} を \noindent\begin{tabularx}{\linewidth} に置き換えると、結果は次のようになります。

ここに画像の説明を入力してください よろしくお願いします。

答え1

問題は、コメントに述べられているように、数式モードに必要な構文を省略していることです。このため、TeX はある時点で、数式モード_でのみ有効な文字である a を読み取ります。したがって、数式モードに自動的に切り替わりますが、数式モードをどこで終了すべきかがわからないため、数式モードでタイプセットが続けられ、この奇妙な出力が発生します。

数式モードの正しい構文を使用すれば、この問題を簡単に解決できます。列 1 と 3 には段落は必要ないので、別の列定義に切り替えることもできます。

\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}

ここに画像の説明を入力してください

パッケージの助けを借りて代替ソリューションを作成することもできますbooktabs。これにより、セル間の境界線の量を減らすことができます。

\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}

ここに画像の説明を入力してください


2 列レイアウトでテーブルをテキスト列の幅まで拡張する場合は、0.8\textwidthを に置き換える必要があることに注意してください。\linewidth

\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}

ここに画像の説明を入力してください

答え2

これは2番目の表を補完するアイデアです@JasperHabicht の回答: 両端の空白スペースを削除し、列 1 で改行を許可します。

ここに画像の説明を入力してください

\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}

関連情報