% \iffalse meta-comment
% enumitem-zref : 2010/05/07 v1.0 - 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/05/07 v1.0 - 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/05/07 v1.0 - 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/05/07}
\def\thisversion{1.0}
\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 in 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 in 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}{302pt}{|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 (see kvsetkeys.dtx).
\ProvidesPackage{linegoal}
         [2010/05/07 v1.0 - 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-\zposx{linegoal.\the\LNGL@unique}sp%
            +\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/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