Page Layouttexpos TPMargin = 0

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
oaox
Posts: 1
Joined: Mon Mar 27, 2017 11:23 pm

texpos TPMargin = 0

Post by oaox »

Some observetions when putting a fbox inside a TPbox:

When setting TPMargin = 0 I get an about 2.4mm margin between the top of the fbox and the TPbox.

With TPMargin=0 and block reference point [0,1] (lower left corner) the positioning is fine with the showboxes option enabled, but shifts about 15mm down without the showboxes option.

Still with TPMargin=0 and now the reference point [0,0] (upper left corner) the vertical shift caused by turning showboxes on and off is about 2.4mm,corresponding to the extra margin mentioned above.

These problems disappear when I set the TPMargin to some small value, like 0.001mm.

Good to know.

\documentclass[10pt,a4paper]{letter}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX,Scale=.92}
\setmainfont{Lucida Bright OT}
\setsansfont{Lucida Sans OT}
\setmonofont{Lucida Sans Typewriter OT}

\usepackage[absolute,showboxes]{textpos}%
%\usepackage[absolute]{textpos}%
\setlength{\TPHorizModule}{1mm}%
\setlength{\TPVertModule}{1mm}%
\TPMargin{0.0001mm}
\setlength{\TPboxrulesize}{0.1mm}

% #1: height, #2: width,#3 text,#4 hpos, #5 vpos
\newcommand{\onelabel}[6]{%
\begin{textblock*}{#6mm}[0,0](#4mm,#5mm)%
\fbox{\parbox[c][#2mm][c]{#1mm}{#3}}%
\end{textblock*}}%

\setlength{\fboxsep}{0pt}
\setlength{\baselineskip}{0pt}

\setlength{\fboxrule}{0.14mm}

\textblockorigin{0mm}{0mm}
\begin{document}

% parbox: width, height, text, TPbox: x, y, width
\onelabel{40.00}{30.00}{txt}{30.00}{100.00}{100}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

texpos TPMargin = 0

Post by Stefan Kottwitz »

Welcome to the forum!

Interesting. Setting it to zero has no effect at all, since only positive values are taken. From textpos.sty:

Code: Select all

\newcommand{\TPMargin@inner}[1]{%
  \TP@margin=#1\relax
  \ifdim\TP@margin < 0pt
    \PackageError{textpos}
      {\protect\TPMargin\space must have a positive argument}
      {\protect\TPMargin\space must have a positive argument}
  \fi
  \TP@absmargin=\TP@margin
}
I looked at the code and did not yet find a reason, why there's this skip when \TP@absmargin=0. I will take another look later. It seems to be a bug.

Stefan
LaTeX.org admin
Post Reply