0

How can I add an option to a certain package through the preamble without modifying the *.sty file itself. I need to propose an additional option to the varioref package, I need to test such modification before contacting the package maintainer.

Here are the lines of code I need to add/test (As described in Defining a new language in Cref):

\DeclareOption{arabic}
  {\vref@addto\extrasarabic{%
    \def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
    \def\reftextfacebefore{on the \reftextvario{facing}{preceding}
                           page}%
    \def\reftextafter     {on the \reftextvario{following}{next} page}%
    \def\reftextbefore    {on the \reftextvario{preceding}{previous} page}%
    \def\reftextcurrent   {on \reftextvario{this}{the current} page}%
    \def\reftextfaraway#1{on page~\pageref{#1}}%
    \def\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
  }}
  • 2
    I usually copy the file I want to modify into a new, empty folder and apply the modifications there. Then I can test the new code from .tex documents that are placed in the same folder. But only documents in the same folder will pick up the new local file, all other documents will still use the globally installed file. Is there anything that prevents you from going with that approach? Sometimes code you want to add to a package can be tested directly from the preamble, but adding options is a bit more tricky, I presume, so the local test file method would be quite natural here. – moewe Sep 8 '19 at 20:00
  • @moewe, So I place the *.sty file and *.tex file in the same folder and modify the *.sty file. Upon running the *.tex file, it will capture the modified *.sty file and not the global one? – Silva Sep 8 '19 at 20:03
  • 1
    Yes. If both files are in the same directory and LaTeX is run as normal, then the .tex file will pick up the local, modified file and not the global .sty. If you later delete the local .sty or place your .tex file in any other folder, the globally installed .sty will be used. – moewe Sep 8 '19 at 20:08
  • After confirming that the changes in the altered file are correctly doing what you intend, you can use the patch technique to put just the changes in your preamble, so that the production job will use the default version of the package. (Make sure the altered test version is out of the way.) – barbara beeton Sep 8 '19 at 21:10
  • 2
    Note an arabic option just got added to varioref today github.com/latex3/latex2e/commit/… – David Carlisle Sep 8 '19 at 23:05

Your Answer

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

Browse other questions tagged or ask your own question.