summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/linegoal/linegoal.sty
blob: b5180c41a087b829ba473e49569af5a7850c1dab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
%%
%% This is file `linegoal.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% linegoal.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% linegoal : 2011/02/25 v2.9 - linegoal : a new dimen corresponding to the remainder of the line
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any later
%% version. The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% 
%% This work consists of the main source file linegoal.dtx
%% and the derived files
%%    linegoal.sty, linegoal.pdf, linegoal.ins
%% 
%% linegoal : linegoal : a new dimen corresponding to the remainder of the line
%% Copyright (C) 2010 by Florent Chervet <florent.chervet@free.fr>
%% 
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX)
   [2005/12/01]% LaTeX must be 2005/12/01 or younger
\ProvidesPackage{linegoal}
         [2011/02/25 v2.9 - Measuring the remaining width of the line]
\ifdefined\pdfsavepos\else % works also in dvi mode
   \PackageWarning{linegoal}
      {This package requires pdfTeX for its \string\pdfsavepos\space primitive\MessageBreak
      pdfTeX has not been detected and \string\linegoal\space will expand\MessageBreak
      to \string\linewidth\space in any case}
   \gdef\linegoal{\linewidth}%
   \expandafter\endinput
\fi
\RequirePackage{etex,zref,zref-savepos}
\zref@newprop*{linegoal}[\linewidth]{\dimexpr
   \linewidth -\the\pdflastxpos sp
   +\ifodd\zref@extractdefault{linegoal/posx.\the\LNGL@unique}{page}\c@page
      \oddsidemargin
   \else\evensidemargin
   \fi
   +1in+\hoffset
   \relax
}% linegoal zref-property
\newcommand*\linegoal{%
   \zref@extract{linegoal.\the\LNGL@unique}{linegoal}\LNGL@setlinegoal
}% \linegoal
\globcount \LNGL@unique
\globdimen \LNGL@tempdim
\def\LNGL@setlinegoal {\relax \LNGL@set@linegoal}
\protected\def\LNGL@set@linegoal{\csname LNGL@set\ifdefined\calc@next!\fi\endcsname}
\expandafter\def\csname LNGL@set!\endcsname!{!\LNGL@set}
\protected\def\LNGL@set{%
   \@bsphack
      \if@filesw
         \pdfsavepos
         \zref@refused{linegoal.\the\LNGL@unique}%
         \LNGL@tempdim\zref@extractdefault{linegoal.\the\LNGL@unique}{linegoal}\maxdimen
         \zref@labelbyprops{linegoal/posx.\the\LNGL@unique}{page,posx}%
         \zref@labelbyprops{linegoal.\the\LNGL@unique}{linegoal}%
         \ifdim\zref@extract{linegoal.\the\LNGL@unique}{linegoal}=\LNGL@tempdim
               \LNGL@info
         \else \expandafter\LNGL@warn%
                  \number\zref@extractdefault{linegoal/posx.\the\LNGL@unique}{page}\c@page\relax
         \fi
         \global\advance\LNGL@unique\@ne
      \else\LNGL@noauxerr
      \fi
   \@esphack
}% \LNGL@set
\def\LNGL@noauxerr{\PackageError{linegoal}
   {\string\linegoal\space does not work if output file are disabled
   \MessageBreak please check the value of \string\if@filesw!}\@ehd
}% \LNGL@noauxerr
\def\LNGL@warn#1\relax{\PackageWarning{linegoal}
   {\string\linegoal\space value on page #1 has changed
   \MessageBreak since last run. Please rerun to get
   \MessageBreak the correct value}%
}% \LNGL@warn
\def\LNGL@@info{\message{Package linegoal Info:
   \string\linegoal=\the\LNGL@tempdim\on@line, page \the\c@page}}
\let\LNGL@info\@empty
\DeclareOption{verbose}{\let\LNGL@info \LNGL@@info}
\ProcessOptions
\endinput
%%
%% End of file `linegoal.sty'.