0

That my whole codes compiled, some pages are below.

odd page enter image description here even page enter image description here

My problem, the longtable does not start left in even pages. That I want, add to the marginparwidth and marginparsep.

Here the even page what I want. enter image description here

Here the MWE

\documentclass[a4paper,twoside,openright,12pt]{book}
\usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{longtable}
\usepackage{showframe}
\usepackage{lipsum}

\begin{document}

\lipsum[1-3]

\begin{longtable}[l]{|p{7cm}|p{7cm}|}
\hline
The power delivered at each instant, of course, varies with the
magnitude of the sinusoidal ac current & The power delivered at each instant, of course, varies with the magnitude of the sinusoidal ac current\\
\hline
\end{longtable}

\end{document}

I am thinking this like...

\checkoddpage
\ifoddpage
START -(\marginparsep+\marginparwidth)
\else
NOTHING DO
\fi

What should I do?

6
  • odd pages should be right-hand pages, so the reason is somewhere else. You did use \cleardoublepage constently, right?
    – Johannes_B
    Apr 27, 2015 at 9:05
  • The layout is pretty unclear. What's the purpose of marginparwidth=5.5cm? Where should the header go? Apr 27, 2015 at 19:32
  • @Heiko, later I edited my question. The purpose is add to marginparwidth, figure, equation, schematic area.
    – Özgür
    Apr 27, 2015 at 20:22
  • @HeikoOberdiek, I edited the my question.
    – Özgür
    Apr 27, 2015 at 20:45
  • you can not change the margin of longtable at a page break, just as you can not change the margin of text paragraphs. Why do you have the wide marginpar area and then try to make longtable overprint it? Apr 27, 2015 at 21:57

2 Answers 2

1

\begin{center} around longtable does not affect alignment, it just adds spurious vertical space.

longtable is centred by default, but if you want left alignment you can use

\begin{longtable}[l]

but you can not align it at all as it is much too wide

Overfull \hbox (95.13185pt too wide) in alignment at lines 16--21

You don't have room for two 7cm columns,

 {|p{7cm}|p{7cm}|}

make those 5cm

2
  • Add your answer to my question. I am sorry for my English. I am not exactly writing my question. Both odd and even pages longtable starts left. @David Charlisle.
    – Özgür
    Apr 27, 2015 at 10:13
  • @Özgür the table has to fit in the text area you have specified for the page, not in the margin area. It is flush left to the text block (and overprints the right margin as you have made it too wide) Apr 27, 2015 at 11:07
1

Starting left on even pages

Package showframe visualizes very good, why the table does start quite with an indentation on even pages. As can be seen, the head line is also moved and the left space is occupied by quite a large "marginpar" column with width 5.5cm. Therefore you might want to correct the option values for package geometry.

Too wide table

Since the table is too wide, see Davids's answer, the column widths need to be reduced. Package tabularx with its X columns can be used for tables, that fit on one page. There are also some packages, which deal with the union of longtable with tabularx, which can be used here.

The example below calculates the maximum width. The table head specification is easy enough.

Each column gets on is left and right side the space \tabcolsep (unless overwritten in the table specification). If package array is loaded, then also the rules contributes to the space. Caution, package array is often loaded by other packages. Therefore the example implements a test for the package at the end of the preamble.

The calculation can be done in many different ways. Examples are package calc, e-TeX's \dimexpr, package pgfmath. The example restricts itself to the basic LaTeX commands \setlength and \addtolength.

\documentclass[a4paper,twoside,openright,12pt]{book}
\usepackage[
  left=1.5cm,
  right=1cm,
  top=3cm,
  bottom=1.5cm,
  marginparwidth=5.5cm,
  marginparsep=1cm,
  outer=8cm
]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{array}
\usepackage{longtable}
\usepackage{showframe}
\usepackage{lipsum}

\newdimen\TabColWidth

\makeatletter
\newif\ifPackageArray
\AtBeginDocument{\@ifpackageloaded{array}{\PackageArraytrue}{}}
\makeatother

\begin{document}

\lipsum[1-3]

\setlength{\TabColWidth}{\linewidth}
\addtolength{\TabColWidth}{-4\tabcolsep}
\ifPackageArray
  \addtolength{\TabColWidth}{-3\arrayrulewidth}
\fi
\setlength{\TabColWidth}{.5\TabColWidth}

\begin{longtable}[l]{|p{\TabColWidth}|p{\TabColWidth}|}
\hline
The power delivered at each instant, of course, varies with the
magnitude of the sinusoidal ac current & The power delivered at each
instant, of course, varies with the magnitude of the sinusoidal ac current\\
\hline
\end{longtable}

\end{document}

Result

1
  • I can't do it. I edited my question.
    – Özgür
    Apr 27, 2015 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .