2

According to this topic How to design a command inquiring internally required packages? I am getting in trouble with the package storebox.

Have a look at this MWE example.

compiling with pdflatex, everything fine...

this example works
\documentclass{article}

\usepackage{storebox}
\usepackage{tcolorbox}

\begin{document}

test
\end{document}

compiling with pdflatex, everything fine, but storebox is disabled...

this example also works
\documentclass{article}


\usepackage{tcolorbox}
\usepackage[disable]{storebox}

\begin{document}
test

\end{document}

compiling this example, getting an error...

this example wont work
\documentclass{article}


\usepackage{tcolorbox}
\usepackage{storebox}

\begin{document}

test
\end{document}

but the following is the desired one...

\makeatletter
\let\req@onefilewithoptions\@onefilewithoptions
\def\@onefilewithoptions#1[#2][#3]#4{%
  \req@push{#1.#4}%
  \req@onefilewithoptions{#1}[{#2}][{#3}]{#4}%
  \req@pop
}

\let\req@list\@empty
\let\req@item\relax
\let\req@top\relax
\newcounter{req@count}
\def\req@push#1{%
  % \typeout{*** [#1]}% debug
  \ifcase\value{req@count}%
    \@ifundefined{req@#1}{%the file, whose package dependencies 
      \global\expandafter
      \let\csname req@#1\endcsname\@empty
      \xdef\req@list{%
        \req@list
        \req@item{#1}%
      }%
    }{}%
    \xdef\req@top{#1}%
    \edef\req@tmp{%
      \noexpand\AtBeginDocument{%
        \noexpand\stepcounter{req@count}%
        \xdef\noexpand\req@top{#1}%
      }%
    }%
    \req@tmp
  \else
    \expandafter\ifx\csname req@\req@top\endcsname\@empty
      \expandafter\xdef\csname req@\req@top\endcsname{#1}%
    \else
      \edef\req@tmp{%
        \noexpand\in@{,#1,}{,\csname req@\req@top\endcsname,}%
      }%
      \req@tmp
      \ifin@
      \else
        \expandafter\xdef\csname req@\req@top\endcsname{%
          \csname req@\req@top\endcsname
          ,#1%
        }%
      \fi
    \fi
  \fi
  \stepcounter{req@count}%
}
\def\req@pop{%
  \addtocounter{req@count}{-1}%
  \ifcase\value{req@count}%
    \global\let\req@top\relax
    \AtBeginDocument{%
      \addtocounter{req@count}{-1}%
      \global\let\req@top\relax
    }%
  \fi
}

\def\req@process{%
  \typeout{Requirement list}%
  \typeout{================}%
  \let\req@item\req@process@item
  \req@list 
  \typeout{================}%
}
\def\req@process@item#1{%
  \typeout{* #1\req@info{#1}}%
  \expandafter\@for\expandafter\req@tmp
  \expandafter:\expandafter=\csname req@#1\endcsname\do{%
    \typeout{ \space> \req@tmp\req@info{\req@tmp}}%
  }%
}
\def\req@info#1{%
  \@ifundefined{ver@#1}{}{ [\@nameuse{ver@#1}]}%
}
\AtEndDocument{\req@process}%
\makeatother

% this example also wont work because there is content in the page which should not appear
\documentclass{article}


\usepackage{tcolorbox}
\usepackage{storebox}

\begin{document}
test

\end{document}

At the one and only page I should read "test". But I can read "req@count-1test"

I like the code of generating the filelist, because I parse this file and include the resulting csv in reports (or I want to).

EDIT 1:

The problem egreg pointed out is the second one I determined during trying to find a solution for example 4. There is content in the first page of the pdf which should not be here.

I want to see "test" in the document but nothing else. What I can see ist "req@count-1test" which seems to me strange...

7
  • Sorry but what's the problem loading putting \usepackage{storebox} before \usepackage{tcolorbox}? Why can't you do that? I assume it has something to do with the changes you want to make before (??) \documentclass but it isn't really clear.
    – cfr
    Jan 5 '16 at 23:38
  • 1
  • It's a bug I already pointed out in 2013. In the linked question I also suggest a temporary workaround.
    – egreg
    Jan 5 '16 at 23:42
  • @egreg this does not solve the problem, that content appear in the resulting pdf. I can compile the last example. But I see more content than expected. Jan 5 '16 at 23:53
  • @cfr this referes to the example of egreg. The suggested solution works for example 3, but has no effect on example 4. Jan 5 '16 at 23:56
4

The problem is a bug in storebox already described in Problems combining tikz and storebox: Missing number, treated as zero. With animate, page shipped out with text `graphicx`,

However, due to the code you add at the beginning, the workaround suggested in my answer there is ineffective, because the empty group is inserted too late. Instead of \ifdim, the \addtocounter instruction from \req@pop is gobbled, causing the printing of its argument.

You can fix the bug in this case with

\def\req@pop{%
  \addtocounter{req@count}{-1}%
  \ifcase\value{req@count}%
    \global\let\req@top\relax
    \AtBeginDocument{%
      \relax\addtocounter{req@count}{-1}% <---- ADDED \relax
      \global\let\req@top\relax
    }%
  \fi
}

The \relax will do nothing special for other included files, but in the case of storebox-pgf it will provide the “missing token” that will be gobbled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.