我有以下代码,其中列出了 3 个问题及其解决方案:
\documentclass[ngerman,12pt,a4paper,oneside,listof=totoc,plainfootsepline]{scrbook}
\addtokomafont{disposition}{\rmfamily}
\addtokomafont{captionlabel}{\bfseries}
\RedeclareSectionCommand[beforeskip=-.5\baselineskip,afterskip=.25\baselineskip]{subsubsection}
\begin{document}
\begin{itemize}
\item \textbf{Problem 1}: \\
Text Text Text Text Text Text Text Text Text .
\item \textbf{Solution 1}: \\
Text Text Text Text Text Text Text Text Text Text Text (max. 1000mm).
\item \textbf{Problem 2}: \\
Text Text Text Text Text Text Text Text
\item \textbf{Solution 2}: \\
Text Text Text Text Text Text Text Text Text Text Text Text, Text Text.
\item \textbf{Problem 3}:\\
Text Text Text Text Text Text Text.
\item \textbf{Solution 3}: \\
ext Text Text Text Text Text Text Text Text Text Text Text, Text Text, Text Text Text Text Text Text Text Text Text Text Text Text, Text Text.
\end{itemize}
\end{document}
我想把它放入一个表中而不是两列中,我尝试了下面的表格代码:
\documentclass[ngerman,12pt,a4paper,oneside,listof=totoc,plainfootsepline]{scrbook}
\addtokomafont{disposition}{\rmfamily}
\addtokomafont{captionlabel}{\bfseries}
\RedeclareSectionCommand[beforeskip=-.5\baselineskip,afterskip=.25\baselineskip]{subsubsection}
\begin{document}
\begin{table}[h]
\setlength\tabcolsep{3pt} % default: 6pt
\caption{Probleme und Lösungen \cite{Codeleser}}
\begin{tabularx}{\textwidth}{|@{} >{\bfseries}l|X @{}|}
\toprule
\textbf{Problem} & \textbf{Solution} \\
\midrule
Text Text Text Text Text Text Text Text Text .Text Text Text Text Text Text Text Text Text (max. 1000mm).\\
\midrule
Text Text Text Text Text Text Text Text Text . & Text Text Text Text Text Text Text Text Text .\newline Text Text Text Text Text Text Text Text Text .\\
\midrule
AText Text Text Text Text Text Text Text Text\newline Text Text Text Text . & Text Text Text Text Text Text Text Text Text . \newline Text Text Text Text Text Text Text Text Text .\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
编译表格代码后,我得到了如下图像上的表格:
我会感谢每一位提出更好建议的人。提前谢谢大家!
答案1
\documentclass[ngerman,12pt,a4paper,oneside,listof=totoc,plainfootsepline]{scrbook}
\addtokomafont{disposition}{\rmfamily}
\addtokomafont{captionlabel}{\bfseries}
\RedeclareSectionCommand[beforeskip=-.5\baselineskip,afterskip=.25\baselineskip]{subsubsection}
\usepackage{tabularx, booktabs}
\begin{document}
\begin{table}[h]
\caption{Probleme und Lösungen \cite{Codeleser}}
\begin{tabularx}{\textwidth}{>{\bfseries}r X X}
\toprule
& \textbf{Problem} & \textbf{Solution} \\
\midrule
1. &Text Text Text Text Text Text Text Text Text .Text Text Text Text Text Text Text Text Text (max. 1000mm). & Text Text Text Text Text Text Text Text Text.\\
\addlinespace
2. &Text Text Text Text Text Text Text Text Text . & Text Text Text Text Text Text Text Text Text. Text Text Text Text Text Text Text Text Text .\\
\addlinespace
3. & Text Text Text Text Text Text Text Text Text Text Text Text Text . & Text Text Text Text Text Text Text Text Text. Text Text Text Text Text Text Text Text Text.\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}