0

I've made a longtable LONGTABLE 1 and now try to add sells "lang1-2-3-4" like here:TABLE 2

Could you please correct my code for 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}
  • That complicated definition for \n is much more easily carried out with \edef\n{\string\n}; I don't understand the redefinition of the active ^^M, though. It looks wrong. – egreg Mar 29 '16 at 13:32
2

Here is a solution, not using multirow, but makecell and tabularx. I define a new column type (D) which enters each cell in a suitable itemize environment. Makecell ensures you can break lines in cells, and their content is horizontally and vertically centred. Finally, with the ltablex package, a tabularx environment can break across pages.

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

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.