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}}%
  }}
Silva
  • 743
  • 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 08 '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 08 '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 08 '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 08 '19 at 21:10
  • Typically you load a sty file with \usepackage and a tex file with \input.. If you are copying the entire file, you only need one of them. – John Kormylo Sep 08 '19 at 21:27
  • @barbara, Do you happen to have any links/examples emphasizing the use of the patch technique? – Silva Sep 08 '19 at 22:38
  • 2
    Note an arabic option just got added to varioref today https://github.com/latex3/latex2e/commit/8a7c6017f0cafa2ece735c0ddc5aab18c4c1c49e – David Carlisle Sep 08 '19 at 23:05
  • Here are a couple of descriptive answers to previous questions: \renewcommand or \patchcmd (from etoolbox)? and Please tutor the usage of patchcmd and xpatch. See also the user guide for etoolbox (texdoc etoolbox). That said, if an applicable option is now available, as reported by @DavidCarlisle, that's probably a better solution. – barbara beeton Sep 09 '19 at 15:36

0 Answers0