Graphics, Figures & TablesSevere problems with longtable / array

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
pipedevnull
Posts: 3
Joined: Tue Feb 03, 2009 3:20 am

Severe problems with longtable / array

Post by pipedevnull »

Hi Folks.

After a long time of abstinence I return to the LaTeX-World, just to find, that some things have changed unexpectedly.

Problem:

Using longtable or tabular with m{1cm} delivers the expected result. (Attachment lower section) - It's just not centered.

Using >{\center}m{1cm} jostles the lines out of alignment something like attached image (upper section)

Now I know, that the entries are too long for the cell, which is something I'll have to deal with seperately. (Unless somebody happens to have a verbatim cell environment with hard line-break handy, that is :D )

Your help would be greatly appreciated.

And no, I _can't_ fiddle manually, as the tables will be generated automatically.

Thanks in advance,

/pipedevnull

Image_3.png
Image_3.png (60.16 KiB) Viewed 9443 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

Severe problems with longtable / array

Post by marco_d »

Hello,

the code is wrong. It is

Code: Select all

>{\centering}m{1cm}
The other Problem latex does not know where the words are separably. You need the babel-package and you must define the separation of the words.

For more details it is easier to work with a minimal example.

regards
Marco
i am German. I can not use difficult words. :-)
pipedevnull
Posts: 3
Joined: Tue Feb 03, 2009 3:20 am

Severe problems with longtable / array

Post by pipedevnull »

As to the centering problem, it's solved.

It seems as if mdwtables somehow is not completely compatible with the array.sty or colortbl ... no big issue, I'll deal with that later on.

Table-Def was:

Code: Select all

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{tabular}[]{ | M{2cm} | >{\centering}m{2cm} | C{3cm} | >{\raggedright}p{6.5cm} | m{1.4cm}|}
blah & blah & ... \\ \hline
The ">{\centering}m{2cm}" was just for testing purposes to try and isolate the error.

As to the hard-break .. the problem is, that absolutely _NO_ hyphenation shall occur - never, ever, what I urgently need is simply wrapping (e.g. for filenames) and best as a verbatim environment, so no transforms of the initial data is required. Where, how (and why) should I therefore be able to define a potential word-break ?

What I'm basically looking for is a wordwrapper which hardwraps the content of the cell without hyphenating - quite simple concept I suppose.

/pipedevnull
marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

Severe problems with longtable / array

Post by marco_d »

Hello,

here an minimal example. It seems you have to do a manual break. In the following example I am using booktabs. You should read the documentation. In tables it is not allowed to use vertical lines.

Code: Select all

\documentclass[english,parskip=half]{scrreprt}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[left=2cm,right=1.5cm,showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage{array,ragged2e,booktabs}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{blindtext}
\parindent0pt
\begin{document}
\chapter{foo}
\blindtext

\begin{table}[ht]\centering
\newcolumntype{M}[1]{>{\Centering}m{#1}}
\newcolumntype{C}[1]{>{\Centering}p{#1}}
\begin{tabular}{@{}>{\columncolor{white}[0pt][\tabcolsep]}M{2cm}>{\Centering}m{2cm}C{3cm}>{\RaggedRight}p{6cm}>{\columncolor{white}[\tabcolsep][0pt]}m{2cm}@{}}
\toprule\rowcolor{gray!40}%
\textbf{long-word} & \textbf{Created} & \textbf{Filename} & \textbf{Path} & \textbf{Appendix Page} \\ \midrule
ABC12 & 13.07.1995\newline12:56 & \verb@23141234.jpg@ &\verb@C:\some path with \spaces@ & 1\\\midrule
ABC12 & 13.07.1995\newline12:56 & 223141\ldots\newline\ldots223141\ldots\newline\ldots223141.jpg &\verb@C:\some path with \spaces\@\newline\verb@some other path with \spaces\@ & 2\\\midrule
\end{tabular}
\caption{foo bar} 
\end{table}


\blindtext
\end{document}
regards
Marco
i am German. I can not use difficult words. :-)
pipedevnull
Posts: 3
Joined: Tue Feb 03, 2009 3:20 am

Re: Severe problems with longtable / array

Post by pipedevnull »

Thank you for the prompt reply :D

I've already used the booktabs.sty, but in this case - disregarding any typesetting "nonos" - the table format is rigidly enforced and _cannot_ be changed ... period.
- Not to my complete satisfaction, but that's the way life goes, I fear.

Therefore I _must_ use vertical lines, I _must_ use hard-wrap _without_ hyphenation.

Background is, the information must be easily OCR-able in certain circumstances, while remaining perfectly human-readable at the same time and adhering to the standards imposed.

So, I'm looking for a minipage-verbatim environment suitable for tables (>{\begin...} ... blah) which will wrap the text into the fixed width tables and fixed width columns without manual intervention (trust me, nobody wants to manually edit more than 1000 lines of table).

It must be typeset with LaTeX, plus the other constraints
(*Argh! Head to the wall*)

/pipedevnull
marco_d
Posts: 57
Joined: Tue Jan 20, 2009 7:49 pm

Severe problems with longtable / array

Post by marco_d »

pipedevnull wrote: So, I'm looking for a minipage-verbatim environment suitable for tables (>{\begin...} ... blah) which will wrap the text into the fixed width tables and fixed width columns without manual intervention (trust me, nobody wants to manually edit more than 1000 lines of table).
You can use the listings package:

without any formatation:

Code: Select all

\documentclass[english,parskip=half]{scrreprt}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[left=2cm,right=1.5cm,showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage{array,ragged2e,booktabs}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{blindtext}
\parindent0pt
\usepackage{listings}
\lstset{breaklines=true}
\newenvironment{fred}
{\minipage{2cm}\verbatim}
{\endverbatim\endminipage}
\begin{document}
\chapter{foo}
\blindtext

\begin{table}[ht]\centering
\newcolumntype{M}[1]{>{\Centering}m{#1}}
\newcolumntype{C}[1]{>{\Centering}p{#1}}
\begin{tabular}{@{}>{\columncolor{white}[0pt][\tabcolsep]}M{2cm}>{\Centering}m{2cm}C{3cm}>{\RaggedRight}p{6cm}>{\columncolor{white}[\tabcolsep][0pt]}m{2cm}@{}}
\toprule\rowcolor{gray!40}%
\textbf{long-word} & \textbf{Created} & \textbf{Filename} & \textbf{Path} & \textbf{Appendix Page} \\ \midrule
ABC12 & 13.07.1995\newline12:56 & \verb@23141234.jpg@ &\verb@C:\some path with \spaces@ & 1\\\midrule
ABC12 & 13.07.1995\newline12:56 & 223141\ldots\newline\ldots223141\ldots\newline\ldots223141.jpg &
\begin{lstlisting}
C:\some path with \spaces \some other path with \spaces
\end{lstlisting} & 2\\\midrule
\end{tabular}
\caption{foo bar}
\end{table}


\blindtext
\end{document}
Marco
i am German. I can not use difficult words. :-)
Post Reply