Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It seems that neither \textwidth nor \textheight can force the table to fill the whole width.

\documentclass[dvips]{book}
\usepackage[a4paper,margin=20mm,showframe]{geometry}
\usepackage{lscape}
\usepackage{lipsum}
\usepackage{calc}
\usepackage{longtable,array}

\begin{document}
\chapter{One}
\lipsum[1]
\section{One One}
\lipsum[2]

\pagestyle{empty}
\begin{landscape}
\begin{longtable}{|m{0.4\textheight-2\tabcolsep-1.5\fboxrule}|m{0.6\textheight-2\tabcolsep-1.5\fboxrule}|}
\hline
a & b\\\hline
c & d\\\hline
\end{longtable}
\end{landscape}
\pagestyle{plain}

\lipsum[3]
\end{document}

EDIT 1:

I made a correction in the column width, i.e., changing 2\fboxrule to 1.5\fboxrule. The former calculation is wrong because the rule between 2 columns should NOT be calculated twice. I slipped a little here.

And I got an output as follows:

alt text


EDIT 2: It's my real scenario (as opposed to the minimal code)

\documentclass[dvipsnames,rgb,dvips]{book}

\usepackage[a4paper,margin=20mm,showframe]{geometry}
\usepackage{longtable}
\usepackage{array}
\usepackage{calc}
\usepackage{ltablex}
\usepackage{lscape}

\newcounter{No}
\renewcommand{\theNo}{\stepcounter{No}\arabic{No}}
\newenvironment{MyTable}[4]%
{%
    \newcolumntype{A}[1]%
    {%
        >{%
            \begin{minipage}%
                {%
                    ##1\textwidth-2\tabcolsep-1.5\arrayrulewidth%
                }%
                \vspace{\tabcolsep}%
         }%
         c%
        <{\vspace{\tabcolsep}\end{minipage}}%
    }%
    \setcounter{No}{0}%comment out this if you want to continuous numbering for all tables.
    \begin{longtable}%
    {%
            |>{\scriptsize\centering\theNo}A{#1}<{}%
            |>{}A{#2}<{\centering\input{\jobname.tmp}}%
            |>{\centering\lstinputlisting{\jobname.tmp}}A{#3}<{}%
            |>{\scriptsize\arraybackslash}A{#4}<{}%
            |%
    }%
    \hline\ignorespaces%
}%
{%
    \end{longtable}%
}

\newcommand{\Comment}[1]{& & & #1\\\hline}


\usepackage{listings}
\lstset{%
language={PSTricks},
basicstyle=\ttfamily\scriptsize,%
keywordstyle=\color{blue}%,
%backgroundcolor=\color{yellow!30}%
}
\usepackage{fancyvrb}


\def\MyRow{%        
        \VerbatimEnvironment%
        \begin{VerbatimOut}{\jobname.tmp}%
}

\def\endMyRow{%
        \end{VerbatimOut}%      
}



\usepackage{pstricks,pst-node}
\newpsstyle{gridstyle}{%
gridwidth=0.4pt,%default: 0.8pt
gridcolor=Red!20,%default: black
griddots=0,%default: 0 
%
gridlabels=3pt,%default: 10pt
gridlabelcolor=Blue,%default: black
%
subgriddiv=5,%default: 5
subgridwidth=0.2pt,%default: 0.4pt
subgridcolor=Green!20,%default: gray
subgriddots=0%default: 0
}

\usepackage{lipsum}

\begin{document}
\chapter{Introduction to PSTricks}
\lipsum[1]

\section{At a glance galleries}
\lipsum[1-5]

%Landscape starts here.
%\pagestyle{empty}
\begin{landscape}
\thispagestyle{empty}
\begin{MyTable}{0.05}{.25}{0.4}{0.3}%
%=============
\begin{MyRow}
\pspicture*[showgrid](4,4)
\pnode(1,1){A}
\pnode(3,3){B}
\ncline{A}{B}
\endpspicture
\end{MyRow}
\Comment{\lipsum[1]}
%=============
\begin{MyRow}
\begin{pspicture}[showgrid](4,3)
\psframe*[linecolor=red!30](3,2)
\end{pspicture}
\end{MyRow}
\Comment{\lipsum[2]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=green!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[3]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=yellow!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[4]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=Maroon!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[5]}
%=============
\end{MyTable}
%Landscape stops here.
\end{landscape}
%\pagestyle{plain}

\section{Node}
\lipsum[1-5]
\end{document}

Unfortunately, \arrayrulewidth does not work.


EDIT 3:

dvips has been added for both code snippets above. The \arrayrulewidth still cannot work the way we want.

share|improve this question
    
do you run latex or pdflatex? –  Herbert Dec 24 '10 at 6:57
    
@Herbert, I always use latex.exe because I use PSTricks package. –  xport Dec 24 '10 at 7:02
    
then use always the dvips option in the document header to tell geometry how it should pass the page dimensions to the program dvips (see my header) –  Herbert Dec 24 '10 at 7:16

2 Answers 2

up vote 3 down vote accepted

Here is my solution

\documentclass[dvipsnames,rgb,dvips]{book}

\usepackage[a4paper,margin=20mm,showframe]{geometry}
\usepackage{longtable}
\usepackage{array}
\usepackage{calc}
\usepackage{ltablex}
\usepackage{lscape}
\usepackage{ragged2e}

\newcounter{No}
\renewcommand{\theNo}{\stepcounter{No}\arabic{No}}
\newcolumntype{A}[1]{%
  >{\vspace*{\medskipamount}\Centering}
  p{#1\linewidth-2\tabcolsep-2\arrayrulewidth}
  <{\smallskip}}
\newenvironment{MyTable}[4]%
  {\setcounter{No}{0}%comment out this if you want to continuous numbering for all tables.
   \begin{longtable}{%
            |>{\scriptsize\theNo}A{#1}<{}%
            |>{}l<{\minipage[t]{#2\linewidth-2\tabcolsep-2\arrayrulewidth}
                   \vspace{0pt}\input{\jobname.tmp}\endminipage}%
            |>{\Centering\lstinputlisting{\jobname.tmp}}A{#3}<{}%
            |>{\scriptsize\arraybackslash}A{#4}<{}%
            |%
    }%
    \hline\ignorespaces%
}%
{%
    \end{longtable}%
}

\newcommand{\Comment}[1]{& & & #1\\\hline}

\usepackage{listings}
\lstset{%
language={PSTricks},
basicstyle=\ttfamily\scriptsize,%
keywordstyle=\color{blue}%,
%backgroundcolor=\color{yellow!30}%
}
\usepackage{fancyvrb}
\def\MyRow{%        
        \VerbatimEnvironment%
        \begin{VerbatimOut}{\jobname.tmp}}

\def\endMyRow{\end{VerbatimOut}}

\usepackage{pstricks,pst-node}
\newpsstyle{gridstyle}{%
gridwidth=0.4pt,%default: 0.8pt
gridcolor=Red!20,%default: black
griddots=0,%default: 0 
%
gridlabels=3pt,%default: 10pt
gridlabelcolor=Blue,%default: black
%
subgriddiv=5,%default: 5
subgridwidth=0.2pt,%default: 0.4pt
subgridcolor=Green!20,%default: gray
subgriddots=0%default: 0
}

\usepackage{lipsum}

\begin{document}
\chapter{Introduction to PSTricks}
\lipsum[1]

\section{At a glance galleries}
\lipsum[1-5]

%Landscape starts here.
%\pagestyle{empty}
\begin{landscape}
\noindent
\rule{\linewidth}{4pt}

\thispagestyle{empty}
\begin{MyTable}{0.05}{.25}{0.4}{0.3}%
%=============
\begin{MyRow}
\pspicture[showgrid](4,4)
\pnode(1,1){A}
\pnode(3,3){B}
\ncline{A}{B}
\endpspicture
\end{MyRow}
\Comment{\lipsum[1]}
%=============
\begin{MyRow}
\begin{pspicture}[showgrid](4,3)
\psframe*[linecolor=red!30](3,2)
\end{pspicture}
\end{MyRow}
\Comment{\lipsum[2]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=green!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[3]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=yellow!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[4]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=Maroon!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[5]}
%=============
\end{MyTable}
%Landscape stops here.
\end{landscape}
%\pagestyle{plain}

\section{Node}
\lipsum[1-5]
\end{document}
share|improve this answer
    
@Herbert, I have to submit my real scenario because the table I used is very tricky (there is a nested minipage inside each cell). Please kindly to see again my edit 2 above. –  xport Dec 24 '10 at 7:16
    
@Herbert, which one is the correct one: 2\arrayrulewidth or 1.5\arrayrulewidth ? –  xport Dec 24 '10 at 8:05
1  
depends to what you want to describe. For a minipage inside a cell -2, for a cell in a tabular header it is one time 2 and all the other 1. For n cells you have n+1 lines. However, for a minipage inside one cell you can choose \columnwidth, then it is correct. –  Herbert Dec 24 '10 at 8:09
1  
@xport-is-sleeping: Your decision. I do not like that. I would use a new letter for another columntype. However, it is possible to overwrite column definitions and it makes no real sense to define a new columntype when you use it only once in the environment, because you can use the definition directly. –  Herbert Dec 24 '10 at 9:19
1  
no, but you can it overwrite it with \newcolumntype –  Herbert Dec 24 '10 at 9:56

use always \linewidth inside the landscape environment and not \textwidth

share|improve this answer
    
thank you very much. Now it works. :-) –  xport Dec 24 '10 at 7:26
    
For the sake of completeness, could you give me a comment whether or not this calculation ##1\linewidth-2\tabcolsep-1.5\fboxrule is correct? –  xport Dec 24 '10 at 7:29
    
Please wait for 1 hour, I have a telephone call. I am sorry. –  xport Dec 24 '10 at 7:30
    
I edited my code, see above –  Herbert Dec 24 '10 at 8:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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