summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/linegoal/linegoal.dtx
blob: 08a6339c1eb794bcf6ca74564bb3717b46794d0b (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
% \iffalse meta-comment
% linegoal : 2010/06/06 v1.1 - 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
%
% Unpacking:
%    (a) If linegoal.ins is present:
%           etex linegoal.ins
%    (b) Without linegoal.ins:
%           etex linegoal.dtx
%    (c) If you insist on using LaTeX
%           latex \let\install=y\input{linegoal.dtx}
%        (quote the arguments according to the demands of your shell)
%
% Documentation:
%           (pdf)latex linegoal.dtx
% Copyright (C) 2010 by Florent Chervet <florent.chervet@free.fr>
%<*ignore>
\begingroup
  \def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\tracingall \tracingonline=0
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: 2010/06/06 v1.1 - linegoal : a new dimen corresponding to the remainder of the line}
\Msg{************************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

linegoal : 2010/06/06 v1.1 - 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>

\endpreamble
\let\MetaPrefix\DoubleperCent

\generate{%
   \file{linegoal.ins}{\from{linegoal.dtx}{install}}%
   \file{linegoal.sty}{\from{linegoal.dtx}{package}}%
   \file{linegoal.tex}{\from{linegoal.dtx}{example}}%
}

\askforoverwritefalse
\generate{%
   \file{linegoal.drv}{\from{linegoal.dtx}{driver}}%
}

\obeyspaces
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{*     linegoal.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `linegoal.dtx'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}

\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\edef\thisfile{\jobname}
\def\thisinfo{A new ``dimen'' corresponding to the remainder of the line}
\def\thisdate{2010/06/06}
\def\thisversion{1.1}
\def\CTANbaseurl{http://www.ctan.org/tex-archive/macros/latex}
\def\CTANdisplay{CTAN:macros/latex}
\makeatletter\protected\def\CTANhref{\@ifstar\CTANhrefstar\CTANhrefnost}\makeatother
\newcommand*\CTANhrefstar[3][/contrib/]{\href{\CTANbaseurl#1#2}{#3}}
\newcommand*\CTANhrefnost[2][/contrib/]{\href{\CTANbaseurl#1#2}{\nolinkurl{\CTANdisplay#1#2}}}
\let\loadclass\LoadClass
\def\LoadClass#1{\loadclass[abstracton]{scrartcl}\let\scrmaketitle\maketitle\AtEndOfClass{\let\maketitle\scrmaketitle}}
\documentclass[a4paper,oneside]{ltxdoc}
\usepackage[latin1]{inputenc}
\usepackage[american]{babel}
\usepackage[T1]{fontenc}
\usepackage{etex,etoolbox,geometry,lastpage,tocloft,graphicx,xspace,tabularx,fancyhdr,color,bbding,embedfile,framed,multirow,txfonts,multirow,makecell,enumitem,arydshln,atveryend,catchfile}
\usepackage[hyperindex=false,pdfusetitle,colorlinks,pdfpagelabels,pdfencoding=auto]{hyperref}
\usepackage{holtxdoc}
\RequirePackage{grffile,eso-pic}% to include the example
\CodelineNumbered
\usepackage{fancyvrb}
\lastlinefit999
\geometry{top=2cm,headheight=1cm,headsep=.3cm,bottom=1.4cm,footskip=.5cm,left=2.5cm,right=1cm}
\hypersetup{%
  pdftitle={The linegoal package},
  pdfsubject={A new dimen corresponding to the remainder of the line},
  pdfauthor={Florent CHERVET},
  colorlinks,linkcolor=reflink,
  pdfstartview={FitH},
  hyperindex=true,
  pdfkeywords={tex, e-tex, latex, package, zref, linegoal},
  bookmarksopen=true,bookmarksopenlevel=2}
\usepackage{bookmark}
\embedfile{\thisfile.dtx}
\begin{document}
   \DocInput{\thisfile.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{75}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \DoNotIndex{\begin,\CodelineIndex,\CodelineNumbered,\def,\DisableCrossrefs,\~,\@ifpackagelater,\z@,\@ne}
% \DoNotIndex{\DocInput,\documentclass,\EnableCrossrefs,\end,\GetFileInfo}
% \DoNotIndex{\NeedsTeXFormat,\OnlyDescription,\RecordChanges,\usepackage}
% \DoNotIndex{\ProvidesClass,\ProvidesPackage,\ProvidesFile,\RequirePackage}
% \DoNotIndex{\filename,\fileversion,\filedate,\let}
% \DoNotIndex{\@listctr,\@nameuse,\csname,\else,\endcsname,\expandafter}
% \DoNotIndex{\gdef,\global,\if,\item,\newcommand,\nobibliography}
% \DoNotIndex{\par,\providecommand,\relax,\renewcommand,\renewenvironment}
% \DoNotIndex{\stepcounter,\usecounter,\nocite,\fi}
% \DoNotIndex{\@fileswfalse,\@gobble,\@ifstar,\@unexpandable@protect}
% \DoNotIndex{\AtBeginDocument,\AtEndDocument,\begingroup,\endgroup}
% \DoNotIndex{\frenchspacing,\MessageBreak,\newif,\PackageWarningNoLine}
% \DoNotIndex{\protect,\string,\xdef,\ifx,\texttt,\@biblabel,\bibitem}
% \DoNotIndex{\z@,\wd,\wheremsg,\vrule,\voidb@x,\verb,\bibitem}
% \DoNotIndex{\FrameCommand,\MakeFramed,\FrameRestore,\hskip,\hfil,\hfill,\hsize,\hspace,\hss,\hbox,\hb@xt@,\endMakeFramed,\escapechar}
% \DoNotIndex{\do,\date,\if@tempswa,\@tempdima,\@tempboxa,\@tempswatrue,\@tempswafalse,\ifdefined,\ifhmode,\ifmmode,\cr}
% \DoNotIndex{\box,\author,\advance,\multiply,\Command,\outer,\next,\leavevmode,\kern,\title,\toks@,\trcg@where,\tt}
% \DoNotIndex{\the,\width,\star,\space,\section,\subsection,\textasteriskcentered,\textwidth}
% \DoNotIndex{\",\:,\@empty,\@for,\@gtempa,\@latex@error,\@namedef,\@nameuse,\@tempa,\@testopt,\@width,\\,\m@ne,\makeatletter,\makeatother}
% \DoNotIndex{\maketitle,\parindent,\setbox,\x,\kernel@ifnextchar}
% \DoNotIndex{\KVS@CommaComma,\KVS@CommaSpace,\KVS@EqualsSpace,\KVS@Equals,\KVS@Global,\KVS@SpaceEquals,\KVS@SpaceComma,\KVS@Comma}
% \DoNotIndex{\DefineShortVerb,\DeleteShortVerb,\UndefineShortVerb,\MakeShortVerb,\endinput}
% \makeatletter
% \newrobustcmd\ClearPage{\@ifstar\clearpage{}}
% \makeatletter
% \MakeShortVerb{\+}\DeleteShortVerb{\|}\DefineShortVerb{\|}
% \catcode`\§ \active   \def§{\@ifnextchar §{\par\nobreak\vskip-2\parskip}{\par\nobreak\vskip-\parskip}}
% \def\thispackage{\xpackage{{\db\thisfile}}\xspace}
% \def\ThisPackage{\Xpackage{\thisfile}\xspace}
% \def\Xpackage{\@dblarg\X@package}
% \def\X@package[#1]#2{\@testopt{\X@@package{#1}{#2}}{}}
% \def\X@@package#1#2[#3]{\xpackage{#2\footnote{\noindent\xpackage{#2}: \CTANhref{#1}#3}}}
% \def\Underbrace#1_#2{$\underbrace{\vtop to2ex{}\hbox{#1}}_{\footnotesize\hbox{#2}}$}
%
% \parindent\z@\parskip.4\baselineskip\topsep\parskip\partopsep\z@
% \g@addto@macro\macro@font{\macrocodecolor\let\AltMacroFont\macro@font}
% \g@addto@macro\@list@extra{\parsep\parskip\topsep\z@\itemsep\z@}
% \DefineVerbatimEnvironment{VerbLines}{Verbatim}{gobble=1,frame=lines,framesep=6pt,fontfamily=txtt,fontseries=m}
% \def\smex{\leavevmode\hb@xt@2em{\hfil$\longrightarrow$\hfil}}
% \newrobustcmd\verbfont{\usefont{T1}{\ttdefault}{\f@series}{n}}    \let\vb\verbfont
% \newrobustcmd\vbbf{\usefont{T1}{\ttdefault}bn}
% \renewrobustcmd\#[1]{{\usefont{T1}{pcr}{bx}{n}\char`\##1}}
% \newrobustcmd\csred[1]{\textcolor{red}{\cs{#1}}}
% \renewrobustcmd\cs[2][]{\mbox{\vb#1\expandafter\@gobble\string\\#2}}
% \newrobustcmd\CSbf[1]{\textbf{\CS{#1}}}
% \newrobustcmd\csbf[2][]{\textbf{\cs[{#1}]{#2}}}
% \newrobustcmd\textttbf[1]{\textbf{\texttt{#1}}}
% \renewrobustcmd*\bf{\bfseries}\newcommand\nnn{\normalfont\mdseries\upshape}\newcommand\nbf{\normalfont\bfseries\upshape}
% \newrobustcmd*\blue{\color{blue}}\newcommand*\red{\color{dr}}\newcommand*\green{\color{green}}\newcommand\rred{\color{red}}
% \newrobustcmd\rrbf{\color{red}\bfseries}
% \definecolor{copper}{rgb}{0.67,0.33,0.00}  \newcommand\copper{\color{copper}}
% \definecolor{dg}{rgb}{0.02,0.29,0.00}      \newcommand\dg{\color{dg}}
% \definecolor{db}{rgb}{0,0,0.502}           \newcommand\db{\color{db}}
% \definecolor{dr}{rgb}{0.49,0.00,0.00}      \let\dr\red
% \definecolor{lk}{rgb}{0.2,0.2,0.2}         \newrobustcmd\lk{\color{lk}}
% \newrobustcmd\bk{\color{black}}\newcommand\md{\mdseries}
% \newrobustcmd\ie{\emph{ie.}}
% \newrobustcmd\textt[2][]{\texttt{#1#2}}
% \newcommand\cellstrut{}\let\cellstrut\bottopstrut
%
% \fancyhf{}\fancyhead[L]{\footnotesize\color[gray]{.35} The \thispackage package -- \thisinfo}
% \fancyfoot[L]{\color[gray]{.35}\scriptsize\thispackage\quad[rev.\thisversion]\quad\copyright\oldstylenums{2010}\,\lower.3ex\hbox{\NibRight}\,Florent Chervet}
% \fancyfoot[R]{\oldstylenums{\thepage} / \oldstylenums{\pageref{LastPage}}}
% \pagestyle{fancy}
% \fancypagestyle{plain}{%
%     \let\headrulewidth\z@
%     \fancyhf{}%
%     \fancyfoot[R]{\oldstylenums{\thepage} / \oldstylenums{\pageref{LastPage}}}}
%
% \newcommand\macrocodecolor{\color{macrocode}}\definecolor{macrocode}{rgb}{0.18,0.00,0.45}
% \newcommand\reflinkcolor{\color{reflink}}\definecolor{reflink}{rgb}{0.49,0.00,0.00}
% \newrobustcmd\stform{\@ifnextchar*{\@stform[]\textasteriskcentered\@gobble}\@stform}
% \newrobustcmd\@stform[2][\string]{\textttbf{\rred#1#2}\xspace}
%
% \makeatother
%
% \deffootnote{1em}{0pt}{\rlap{\textsuperscript{\thefootnotemark}}\kern1em}
%
% \title{\vspace*{-28pt}\mdseries The {\bfseries\thispackage\footnotemark}\kern.6em package}
% \author{\tiny\xemail{florent.chervet at free.fr}}
% \date{\thisdate~--~version \thisversion}
% \subtitle{\thisinfo}
% ^^A\subject{\thisinfo}
% \maketitle
%
% \makeatletter\begingroup\let\@thefnmark\@empty\let\@makefntext\@firstofone
% \footnotetext{\noindent
% This documentation is produced with the +DocStrip+ utility.
% \begin{tabbing}
% \qquad\=\smex\=To get the documentation, \= run (thrice):\quad\= \texttt{pdflatex \thisfile.dtx} \\
% \qquad\>\>To get the index, \> run:\>\texttt{makeindex -s gind.ist \thisfile.idx} \\
% \>\smex\>To get the package, \> run:\>        \texttt{etex \thisfile.dtx}
% \end{tabbing}§
% The \xext{dtx} file is embedded into this pdf file thank to \xpackage{embedfile} by H. Oberdiek.}
% \endgroup\makeatother
%
% \deffootnote{1em}{0pt}{\rlap{\thefootnotemark.}\kern1em}
% \vspace*{-26pt}
% \begin{abstract}\parindent0pt\noindent\leftskip1cm\rightskip\leftskip\lastlinefit0%
%
% \thispackage provides a macro \csbf{linegoal} which expands to the dimension of the remainder of the line.
% It requires pdf\TeX{} for its \cs{pdfsavepos} primitive. Two compilations (at least) are necessary to get
% the correct line goal.
% \medskip
%
% More precisely: \cs{setlength} is overloaded so that:§
% \hfil\cs{setlength}\cs{mydimen}\{\cs{linegoal}\}\hfil\null§
% sets \cs{mydimen} to be the (horizontal) length of the remainder of the current line. This can be useful for
% use with \xpackage{tabularx} or \xpackage{tabular*} for example (see \nameref{userinterface}).
% \medskip
% 
% \thispackage requires pdf\TeX{} and uses the \xpackage{zref-savepos} module of \Xpackage[/oberdiek/]{zref} package.
%
% \end{abstract}
%
% \DeleteShortVerb{\+}\enlargethispage{\baselineskip}
% \cftbeforesecskip=4pt plus2pt minus2pt
% \cftbeforesubsecskip=0pt plus2pt minus2pt
% \renewcommand\contentsname{\vspace*{-12pt}Contents\quad\leaders\vrule height3.4pt depth-3pt\hfill\null\kern0pt\vskip-6pt}
% ^^A\vskip-.8\baselineskip
% \tableofcontents
% \leavevmode\leaders\vrule height3.4pt depth-3pt\hfill\null
% \ClearPage
% \hypersetup{bookmarksopenlevel=2}
%
% ^^A\clearpage
% \MakeShortVerb{\+}
%
% \def\B#1{\texttt{[}\meta{#1}\texttt{]}}
%
% \section{User interface}
% \label{userinterface}
% 
% \begin{VerbLines}
% This is a tabular that fills the remainder of the line:
%     \begin{tabularx}\linegoal{|l|X|}\hline
%        Something & Something else \\
%        Something & Something else \\\hline
%     \end{tabularx}
% \end{VerbLines}
% 
% \DeleteShortVerb{\+}
% \tracingtabularx
% 
% This is a tabular that fills the remainder of the line:
% \ifcsname ver@linegoal.sty\endcsname
% \begin{tabularx}\linegoal{|l|X|}\hline
%  Something & Something else \\
%  Something & Something else \\\hline
% \end{tabularx}
% \else
% \begin{tabularx}{279.6pt}{|l|X|}\hline
%  Something & Something else \\
%  Something & Something else \\\hline
% \end{tabularx}%
% \fi
% 
% 
% \StopEventually{
% }
%
% \hypersetup{bookmarksopenlevel=1}
% \section{Implementation} \label{sec:implementation}
% \csdef{HDorg@PrintMacroName}#1{\hbox to4em{\strut \MacroFont \string #1\ \hss}}
%
% \subsection{Identification}
%
% \begin{itemize}
% \item This package is intended to use with \LaTeX{} so we don't check if it is loaded twice.
% \item The package namespace is \textttbf{\db\string\LNGL@}
% \end{itemize}
%
%    \begin{macrocode}
%<*package>
\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}
         [2010/06/06 v1.1 - A new dimen corresponding to the remainder of the line]
\def\LNGL@pkg@name{linegoal}
%    \end{macrocode}
%
% \subsection{Requirements}
%
% The package requires \xpackage{zref} and its module \xpackage{zref-savepos}.
%
%    \begin{macrocode}
\ifdefined\pdfsavepos\else
   \PackageWarning\LNGL@pkg@name
      {This package requires pdfTeX for its \string\pdfsavepos primitive\MessageBreak
      pdfTeX has not been detected and \LNGL@pkg@name\space will not be loaded}%
   \expandafter\endinput
\fi
\RequirePackage{etex,zref,zref-savepos}
%    \end{macrocode}
% 
% \subsection{zref property : page as arabic number}
% 
%    \begin{macrocode}
\zref@newprop*{LNGL@page}[0]{\the\c@page}
%    \end{macrocode}
%
% \subsection{The linegoal macro}
%
%\begin{macro}{\linegoal}
%    \begin{macrocode}
\globcount\LNGL@unique
\def\linegoal{linegoal}
\def\set@linegoal#1#2{%
   \@bsphack
      \if@filesw
         \global\advance\LNGL@unique\@ne
         \pdfsavepos   
         \zref@labelbyprops{linegoal.\the\LNGL@unique}{posx,LNGL@page}%
         #1=\dimexpr\linewidth-\zref@extractdefault{linegoal.\the\LNGL@unique}{posx}0sp
            +\ifodd\zref@extractdefault{linegoal.\the\LNGL@unique}{LNGL@page}0
                    \oddsidemargin
             \else \evensidemargin
             \fi
            +1in+\hoffset
            \relax
      \fi
   \@esphack
}% \set@linegoal
\AtBeginDocument\LNGL@AtBeginDocument@hook
\def\LNGL@AtBeginDocument@hook{%
   \let\LNGL@ORI@setlength\setlength
   \protected\def\setlength##1##2{%
      \ifx\linegoal##2\expandafter\set@linegoal
      \else           \expandafter\LNGL@ORI@setlength
      \fi{##1}{##2}%
   }% \setlength
}% \LNGL@AtBeginDocument@hook
%    \end{macrocode}
%\end{macro}

%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \DeleteShortVerb{\+}
% \begin{History}
% 
%   \begin{Version}{2010/06/06 v1.1}
%   \item The first release required some small corrections  !
%   \end{Version}
%
%   \begin{Version}{2010/05/07 v1.0}
%   \item First version.
%   \end{Version}
%
% \end{History}
%
% \begin{thebibliography}{9}
%
% \bibitem{zref}
%   Heiko Oberdiek:
%   \textit{The \xpackage{zref} package};
%   2010/05/01 v2.17;
%   \CTAN{macros/latex/contrib/oberdiek/}.
%
% \end{thebibliography}
%
% \PrintIndex
%
% \Finale