Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Left aligned text in cells overflows to the next cell #3

Open
Sveinung58 opened this issue Jul 4, 2019 · 6 comments
Open

Left aligned text in cells overflows to the next cell #3

Sveinung58 opened this issue Jul 4, 2019 · 6 comments
Assignees

Comments

@Sveinung58
Copy link

Sveinung58 commented Jul 4, 2019

In left aligned cells (\alignL) with several lines of text, the text overflows to the next (right) cell. cals also always set left aligned cells justified and do not respect for example a \raggedright -command, whether or not this command is given outside the tabular or inside the cell.

You can avoid the bug by enclose the cell content in a \parbox with the width of the column less the left and right padding. Such parbox will also respect a raggedright-command.

Here is some code that demonstrate the problem:

`\documentclass[a4paper, norsk , 11pt]{article}
\usepackage{cals, babel, mathpazo}

\begin{document}

\begin{calstable}

\colwidths{{\dimexpr(\columnwidth)/185\relax}
{\dimexpr(\columnwidth)/18
5\relax}
{\dimexpr(\columnwidth)/18*5\relax}
}

\makeatletter

% R1
\thead{\bfseries
\brow
\alignL\cell{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}
\alignC\cell{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}
\alignR\cell{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}
\erow
\mdseries
}
% R2 Body
\brow
\alignL\cell{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}
\alignC\cell{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}
\alignR\cell{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}
\erow
% R3 Body
\brow
\alignL\cell{\parbox{\dimexpr(\columnwidth)/18*5-(2\cals@paddingR)\relax}{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}}
\alignC\cell{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}
\alignR\cell{Test av lange tekster i venstrestilte celler i en cals-tabell. Vi må se hvordan det går med ulike alternativer. Dette er egentlig en tullesetning.}
\erow
\makeatletter
\end{calstable}
\end{document}`

@olpa olpa self-assigned this Jul 7, 2019
@olpa
Copy link
Owner

olpa commented Jul 7, 2019

Thanks for the report! I think the issue can not be easily solved.

  • cals relies on \leftskip, \rightskip and other skips to layout text content inside cells. I'd prefer that other packages would not interfere with them
  • cells can be used not only for text content, so forced parbox is not an option

I'm a bit surprised about non-centering. I expect that it should happen even in case of overflow. I'll look at it.

In any case, I consider that special cases should be handled manually. I think if you put raggedright inside \cals@AtBeginCell, it should take the effect.

Also, I think it is possible to define \cals@AtBeginCell as \parbox{...}{ and \cals@AtEndCell as }.

@Sveinung58
Copy link
Author

Sveinung58 commented Jul 8, 2019

Thank you for the feed back. You will see that the text in an alignL cell starts after the left padding, but extend into the left padding of the next cell, i.e. it set the text in the full column width and overflow the right padding in its "own" cell and the left padding in the next.

Interesting, \alingC and \alignR works as expected. However, those commands do not respect \RaggedRight from package ragged2e, neither inside nor outside the cell.

If \alignL is unfixable, maybe it should be documented, and a work-around described.

@vincentb1
Copy link

Dear @olpa ,

Thank you for providing cals. I also observed this issue.

About your comment that

cells can be used not only for text content, so forced parbox is not an option

I understand that your point is that a parbox takes its second argument as a macro argument, and as such content such as \verb!#{_^! would fails, so actually a minipage would be better if you have such kind of contant as \verb!#{_^!. Or did you have any other idea why forcing a parbox is not an option.

My point is rather the following one: I haven't looked as the implementation, but if you are using \leftskip and \rightskip under the hood, why not set this parameters in a way that the text does not spills out. Wouldn't this be a matter of incrementing the \rightskip by 2\tabcolsep or so.

@olpa
Copy link
Owner

olpa commented Apr 30, 2021

why not set this parameters in a way that the text does not spills out

It was an oversight from my side. In my production code on top of cals, I use something like

\setlength{\cals@paddingR}{6pt plus 22pt minus3pt}%

It helps.

I've just noticed in the definition of \alignL

\newcommand\alignL{%
\cals@vfillDrop\cals@paddingL
\cals@vfillDrop\cals@paddingR}

The fill-stretch is dropped, and I suppose \raggedright uses fill. I think if it used only fil, then ragging would work.

Or did you have any other idea why forcing a parbox is not an option.

The \cell command is smart. It supports a verbatim inside.

What is important: the argument of \cell should contain a switch to the horizontal mode, otherwise horizontal dimensions of the cell will be incorrect.

@vincentb1
Copy link

vincentb1 commented May 3, 2021

It was an oversight from my side. In my production code on top of cals, I use something like

Do you mean that the github repo is more up-to-date than the CTAN? I was using the CTAN code…

@olpa
Copy link
Owner

olpa commented May 4, 2021

No, sorry for confusion. I use the line with \setlength in a document preamble. The value of the length becomes the value of \rightskip inside cells.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants