3

What I want to accomplish is to draw a dashed line inside longtable. What is strange is that when arydshln package is loaded I receive a black box for the first row (header) in the first cell. I guess the problem occurs with the combination of longtable, arydshln and \rowcolor.

Is there any solution or any other package that offers dashed lines inside tables except longtabu?

Here my MWE:

\documentclass[paper=a4,fontsize=18pt]{article}
\usepackage{geometry}
\geometry{
    % verbose,
    landscape,      % page orientation (landscape or portrait)
    a4paper,        % paper size
    tmargin=20mm,   % page top margin
    bmargin=20mm,   % page bottom margin
    lmargin=5mm,   % page left margin
    rmargin=5mm % page right maring
}
\usepackage[utf8]{inputenc}
\usepackage[defaultsans]{opensans} %font
\usepackage[T1, T2A]{fontenc}
\usepackage[english,bulgarian]{babel}
\usepackage{longtable} % use this table
\usepackage{colortbl}
\usepackage{makecell}
\usepackage[lutf8x]{luainputenc}
\usepackage{arydshln}


\begin{document}
\begin{longtable}[l] {|
p{30mm}|
p{30mm}|
p{30mm}|
p{15mm}|
p{15mm}|
p{15mm}|
p{30mm}|
p{30mm}|}
\hline\rowcolor{red}
\raisebox{-0.7mm}[0mm][12mm]{ \thead[l]{ Test \textnumero } } &
\raisebox{-0.7mm}[0mm][12mm]{ \thead[l]{ Папка \textnumero } } &
\raisebox{-4mm}[0mm][12mm]{ \thead[l]{ Дата на \\ въвеждане \\ на документа } } &
\raisebox{-2.3mm}[0mm][12mm]{ \thead[l]{ Потре- \\ бител } } &
\raisebox{-2.3mm}[0mm][12mm]{ \thead[l]{ Сметка \\ дебит } } &
\raisebox{-2.3mm}[0mm][12mm]{ \thead[l]{ Сметка \\ кредит } } &
\raisebox{-2.3mm}[0mm][12mm]{ \thead[r]{ ~~~~~~~~~~~~~~~ Стойност \\ дебит } } &
\raisebox{-2.3mm}[0mm][12mm]{ \thead[r]{ ~~~~~~~~~~~~~~~ Стойност \\ кредит } }
\\ \hline \endhead 
test & test &
test & test &
test & test &
test & test\\ \hdashline
\end{longtable}
\end{document}
  • This table can't fit on a4paper, even in landscape! – Bernard Apr 27 '18 at 11:24
  • I can see that @Bernard. This is a MWE of the document. This is not the current problem. – Lubomir Borisov Apr 27 '18 at 11:26
  • I fixed it and now can fit. I still dont have any solution to the main problem. – Lubomir Borisov Apr 27 '18 at 11:31
  • Have a look at this question, perhaps: tex.stackexchange.com/questions/400909/… Looks like you need to load xcolor first. – Paul Stanley Apr 27 '18 at 11:51
  • This is not a problem with arydshln, but with makecell: it sometimes has problems with color in tables. A workaround consists in replacing thead with \Centerstack from the stackengine package. I could propose a code, but I don't quite understand what you're trying to achieve with all these \raisebox in column heads. – Bernard Apr 27 '18 at 11:53
3

You can do it in a simpler way, makecell is not needed and also all those \raisebox commands. With the help of suitable struts we can get some separation between the header cells and the borders.

Avoid luainputenc: it's for legacy documents and should not be used in newer ones.

\documentclass{article}
\usepackage{geometry}
\geometry{
  % verbose,
  landscape,    % page orientation (landscape or portrait)
  a4paper,      % paper size
  tmargin=20mm, % page top margin
  bmargin=20mm, % page bottom margin
  lmargin=5mm,  % page left margin
  rmargin=5mm,  % page right margin
}
\usepackage[english,bulgarian]{babel}
\usepackage{longtable} % use this table
\usepackage{colortbl}
\usepackage{arydshln}
\usepackage{fontspec}

\setmainfont{OpenSans}

\newcommand\mytopstrut{\rule{0pt}{2.5ex}}
\newcommand\mybotstrut{\rule[-1.5ex]{0pt}{1.5ex}}

\begin{document}
\begin{longtable}[l] {
  |
  p{30mm}|
  p{30mm}|
  p{30mm}|
  p{15mm}|
  p{15mm}|
  p{15mm}|
  p{30mm}|
  p{30mm}|
}
\hline\rowcolor{red}
\raggedright\mytopstrut Test \textnumero &
\raggedright\mytopstrut Папка \textnumero &
\raggedright\mytopstrut Дата на въвеждане на документа\mybotstrut &
\raggedright\mytopstrut Потре- бител &
\raggedright\mytopstrut Сметка дебит &
\raggedright\mytopstrut Сметка кредит &
\raggedleft\mytopstrut Стойност \\ дебит &
\raggedleft\mytopstrut Стойност \\ кредит \tabularnewline
\hline
\endhead 
test & test &
test & test &
test & test &
test & test\\ \hdashline
\end{longtable}
\end{document}

enter image description here

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.