我做了一个长桌 现在尝试添加销售“lang1-2-3-4”,如下所示:
您能否修正我的 longtable 代码?
\documentclass[a4paper,12pt]{article}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[turkish,russian]{babel}
%\usepackage[scaled]{helvet}
%\renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be sans serif
\usepackage{fontenc}
\usepackage{longtable}
\usepackage{tcolorbox}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{array}
\usepackage[overwrite=true]{getmap}
\usepackage{calc}
\usepackage[unicode,hidelinks]{hyperref}
\usepackage{geometry} % Меняем поля страницы
\geometry{left=1.5cm}% левое поле
\geometry{right=1.5cm}% правое поле
\geometry{top=1.5cm}% верхнее поле
\geometry{bottom=1.5cm}% нижнее поле
\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}
{\obeylines\gdef^^M{^^J}%
\catcode`\@=0 %
\catcode`\\=12 %
@gdef@n{\n}}
%\newcommand*{\pin}{%pincode map
% \includegraphics[height=\heightof{M}]{pincode}%
%}
\begin{document}
\shorthandoff{=}
\large
\pagestyle{empty}
%LONGTABLE 1
\begin{longtable}{|>{\centering\arraybackslash}p{0.2\textwidth}|p{0.7\textwidth}|}
\hline
\multirow{2}*{\minitab[c]{\textbf{1 April,} \\ \textbf{Friday}}} &\textbf{9.00} "--- event 1.\\
& \textbf{18.00} "--- event 2.\\
\hline
\multirow{3}*{\minitab[c]{\textbf{ 2 April,} \\ \textbf{Saturday}}} & \textbf{8.00} "--- event 1.\\
& \textbf{9.00} "--- event 2.\\
& \textbf{18.00} "--- event 3.\\
\hline
\multirow{4}*{\minitab[c]{\textbf{3 April,} \\ \textbf{Sunday}}} & \textbf{Event EventEventEventEvent EventEvent Event EventEvent.}\\
&\textbf{8.00} "--- event 1.\\
&\textbf{9.00} "--- event 2.\\
\hline
\multirow{2}*{\minitab[c]{\textbf{6 April,} \\ \textbf{Wednesday}}} & \raisebox{-1.5ex}[0cm][0cm]{\textbf{18.00} "--- event 1.}\\
& \\
\hline
\end{longtable}
\end{document}
答案1
这是一个解决方案,不使用多行,而是makecell
和tabularx
。我定义了一个新的列类型(D
),它将每个单元格输入到合适的itemize
环境中。Makecell
确保您可以在单元格中换行,并且其内容水平和垂直居中。最后,使用该ltablex
包,tabularx
环境可以跨页面分行。
\documentclass[a4paper,12pt]{article}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[turkish,russian]{babel}
%\usepackage[scaled]{helvet}
%\renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be sans serif
\usepackage{fontenc}
\usepackage{longtable}
\usepackage{tcolorbox}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{array}
% \usepackage[overwrite=true]{getmap}
\usepackage{calc}
\usepackage[unicode,hidelinks]{hyperref}
\usepackage[showframe]{geometry} % Меняем поля страницы
\geometry{left=1.5cm}% левое поле
\geometry{right=1.5cm}% правое поле
\geometry{top=1.5cm}% верхнее поле
\geometry{bottom=1.5cm}% нижнее поле
\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}}
{\obeylines\gdef^^M{^^J}%
\catcode`\@=0 %
\catcode`\\=12 %
@gdef@n{\n}}
%\newcommand*{\pin}{%pincode map
% \includegraphics[height=\heightof{M}]{pincode}%
%}
\usepackage{ltablex}
\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight}m{#1}}
\newcolumntype{D}{>{\leavevmode\vspace{-\baselineskip}\itemize[leftmargin=2.5em, labelsep=0pt, font=\bfseries, align=right]} X <{\enditemize\vspace*{-\dimexpr\baselineskip+ \topsep\relax}}}
\usepackage{enumitem, ragged2e, makecell}
\renewcommand\theadfont{\normalfont\bfseries}
\begin{document}
\shorthandoff{=}
\large
\pagestyle{empty}
%LONGTABLE 1
\keepXColumns
\begin{tabularx}{\linewidth}{|>{\centering\arraybackslash}m{0.2\textwidth}| D|}%
\hline
\thead{1 April, \\ Friday \\[2ex]
\hspace*{-\tabcolsep}\begin{tabular}{ p{\dimexpr0.1\textwidth-\tabcolsep\relax} |p{\dimexpr0.1\textwidth-\tabcolsep\relax}}%
\hline
lang1 & lang 2\\
\hline
lang3 & lang4\\[-1.5ex]
\end{tabular} } &%
\item[9.00] "--- event 1 %
\item[18.00] "--- event 2.
\\
\hline
\thead{ 2 April, \\ Saturday } & %
\item[8.00] "--- event 1.%
\item[9.00] "--- event 2.%
\item[18.00] "--- event 3.\\
\hline
\thead{3 April, \\ Sunday } & \item[]\textbf{Event EventEventEventEvent EventEvent Event EventEvent.} \item[8.00] "--- event 1.%
\item[9.00] "--- event 2. \\%
\hline
\thead{6 April, \\ Wednesday} &\item[18.00] "--- event 1.
\\
\hline
\end{tabularx}
\end{document}