Is it possible to force a package to be called last in the entirety of the LaTeX, when called in the class...












5















I have designed a class that needs the xepersian package. This package is unique in the way that it needs to be called last so it doesn't get overwritten. I usually define my packages in the class file using the "RequirePackage".
Is there a way to force a package to be called last where it is called in the .cls file with the possibility of other packages being called using the usepackage in the .tex file?










share|improve this question























  • You can use AtBeginDocument{RequirePackage{xepersian}}.

    – Phelype Oleinik
    18 hours ago











  • @PhelypeOleinik I see. Thanks.

    – Al_Fh
    18 hours ago






  • 2





    @campa AfterEndPreamble is too late to load a package. You'll get a LaTeX Error: Can be used only in preamble.. The AtBeginDocument is the latest a package can be loaded because right after that the preamble ends (i.e. preamble-only commands become error messages).

    – Phelype Oleinik
    18 hours ago






  • 4





    @PhelypeOleinik assuming that none of the packages you load later use the same trick to delay some package loading ...

    – Ulrike Fischer
    18 hours ago











  • @UlrikeFischer Ah, yes, there's that. If I recall correctly, there's an infamous Brazilian class file which does something like that and loading hyperref on top of it is a nightmare :-)

    – Phelype Oleinik
    18 hours ago
















5















I have designed a class that needs the xepersian package. This package is unique in the way that it needs to be called last so it doesn't get overwritten. I usually define my packages in the class file using the "RequirePackage".
Is there a way to force a package to be called last where it is called in the .cls file with the possibility of other packages being called using the usepackage in the .tex file?










share|improve this question























  • You can use AtBeginDocument{RequirePackage{xepersian}}.

    – Phelype Oleinik
    18 hours ago











  • @PhelypeOleinik I see. Thanks.

    – Al_Fh
    18 hours ago






  • 2





    @campa AfterEndPreamble is too late to load a package. You'll get a LaTeX Error: Can be used only in preamble.. The AtBeginDocument is the latest a package can be loaded because right after that the preamble ends (i.e. preamble-only commands become error messages).

    – Phelype Oleinik
    18 hours ago






  • 4





    @PhelypeOleinik assuming that none of the packages you load later use the same trick to delay some package loading ...

    – Ulrike Fischer
    18 hours ago











  • @UlrikeFischer Ah, yes, there's that. If I recall correctly, there's an infamous Brazilian class file which does something like that and loading hyperref on top of it is a nightmare :-)

    – Phelype Oleinik
    18 hours ago














5












5








5








I have designed a class that needs the xepersian package. This package is unique in the way that it needs to be called last so it doesn't get overwritten. I usually define my packages in the class file using the "RequirePackage".
Is there a way to force a package to be called last where it is called in the .cls file with the possibility of other packages being called using the usepackage in the .tex file?










share|improve this question














I have designed a class that needs the xepersian package. This package is unique in the way that it needs to be called last so it doesn't get overwritten. I usually define my packages in the class file using the "RequirePackage".
Is there a way to force a package to be called last where it is called in the .cls file with the possibility of other packages being called using the usepackage in the .tex file?







xetex packages






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 18 hours ago









Al_FhAl_Fh

826




826













  • You can use AtBeginDocument{RequirePackage{xepersian}}.

    – Phelype Oleinik
    18 hours ago











  • @PhelypeOleinik I see. Thanks.

    – Al_Fh
    18 hours ago






  • 2





    @campa AfterEndPreamble is too late to load a package. You'll get a LaTeX Error: Can be used only in preamble.. The AtBeginDocument is the latest a package can be loaded because right after that the preamble ends (i.e. preamble-only commands become error messages).

    – Phelype Oleinik
    18 hours ago






  • 4





    @PhelypeOleinik assuming that none of the packages you load later use the same trick to delay some package loading ...

    – Ulrike Fischer
    18 hours ago











  • @UlrikeFischer Ah, yes, there's that. If I recall correctly, there's an infamous Brazilian class file which does something like that and loading hyperref on top of it is a nightmare :-)

    – Phelype Oleinik
    18 hours ago



















  • You can use AtBeginDocument{RequirePackage{xepersian}}.

    – Phelype Oleinik
    18 hours ago











  • @PhelypeOleinik I see. Thanks.

    – Al_Fh
    18 hours ago






  • 2





    @campa AfterEndPreamble is too late to load a package. You'll get a LaTeX Error: Can be used only in preamble.. The AtBeginDocument is the latest a package can be loaded because right after that the preamble ends (i.e. preamble-only commands become error messages).

    – Phelype Oleinik
    18 hours ago






  • 4





    @PhelypeOleinik assuming that none of the packages you load later use the same trick to delay some package loading ...

    – Ulrike Fischer
    18 hours ago











  • @UlrikeFischer Ah, yes, there's that. If I recall correctly, there's an infamous Brazilian class file which does something like that and loading hyperref on top of it is a nightmare :-)

    – Phelype Oleinik
    18 hours ago

















You can use AtBeginDocument{RequirePackage{xepersian}}.

– Phelype Oleinik
18 hours ago





You can use AtBeginDocument{RequirePackage{xepersian}}.

– Phelype Oleinik
18 hours ago













@PhelypeOleinik I see. Thanks.

– Al_Fh
18 hours ago





@PhelypeOleinik I see. Thanks.

– Al_Fh
18 hours ago




2




2





@campa AfterEndPreamble is too late to load a package. You'll get a LaTeX Error: Can be used only in preamble.. The AtBeginDocument is the latest a package can be loaded because right after that the preamble ends (i.e. preamble-only commands become error messages).

– Phelype Oleinik
18 hours ago





@campa AfterEndPreamble is too late to load a package. You'll get a LaTeX Error: Can be used only in preamble.. The AtBeginDocument is the latest a package can be loaded because right after that the preamble ends (i.e. preamble-only commands become error messages).

– Phelype Oleinik
18 hours ago




4




4





@PhelypeOleinik assuming that none of the packages you load later use the same trick to delay some package loading ...

– Ulrike Fischer
18 hours ago





@PhelypeOleinik assuming that none of the packages you load later use the same trick to delay some package loading ...

– Ulrike Fischer
18 hours ago













@UlrikeFischer Ah, yes, there's that. If I recall correctly, there's an infamous Brazilian class file which does something like that and loading hyperref on top of it is a nightmare :-)

– Phelype Oleinik
18 hours ago





@UlrikeFischer Ah, yes, there's that. If I recall correctly, there's an infamous Brazilian class file which does something like that and loading hyperref on top of it is a nightmare :-)

– Phelype Oleinik
18 hours ago










1 Answer
1






active

oldest

votes


















9














You can delay the package loading using AtBeginDocument:



AtBeginDocument{RequirePackage{xepersian}}


this will put the package loading after the .aux file is read but before the “proper end” of the preamble, where all the preamble-only commands are redefined to throw an error; from this point on any usepackage (or RequirePackage) will not work.



If the package, for some reason, needs to be loaded before the begin{document} even starts, then you can load the etoolbox package and use:



BeforeBeginEnvironment{document}{RequirePackage{xepersian}}


this will execute the RequirePackage before executing anything from the begin{document}. The effect is the same as if you had put the RequirePackage line right before begin{document} in your .tex file.






share|improve this answer


























  • What do you mean by the "proper end" of the preamble? Can you clarify?

    – Al_Fh
    18 hours ago











  • @Al_Fh I just invented that name :P I clarified the answer.

    – Phelype Oleinik
    18 hours ago











  • Thank you very much.

    – Al_Fh
    18 hours ago











  • Of course, you can always load xpersian in the preamble (before hyperref). It will not be loaded twice.

    – John Kormylo
    13 hours ago












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f484102%2fis-it-possible-to-force-a-package-to-be-called-last-in-the-entirety-of-the-latex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









9














You can delay the package loading using AtBeginDocument:



AtBeginDocument{RequirePackage{xepersian}}


this will put the package loading after the .aux file is read but before the “proper end” of the preamble, where all the preamble-only commands are redefined to throw an error; from this point on any usepackage (or RequirePackage) will not work.



If the package, for some reason, needs to be loaded before the begin{document} even starts, then you can load the etoolbox package and use:



BeforeBeginEnvironment{document}{RequirePackage{xepersian}}


this will execute the RequirePackage before executing anything from the begin{document}. The effect is the same as if you had put the RequirePackage line right before begin{document} in your .tex file.






share|improve this answer


























  • What do you mean by the "proper end" of the preamble? Can you clarify?

    – Al_Fh
    18 hours ago











  • @Al_Fh I just invented that name :P I clarified the answer.

    – Phelype Oleinik
    18 hours ago











  • Thank you very much.

    – Al_Fh
    18 hours ago











  • Of course, you can always load xpersian in the preamble (before hyperref). It will not be loaded twice.

    – John Kormylo
    13 hours ago
















9














You can delay the package loading using AtBeginDocument:



AtBeginDocument{RequirePackage{xepersian}}


this will put the package loading after the .aux file is read but before the “proper end” of the preamble, where all the preamble-only commands are redefined to throw an error; from this point on any usepackage (or RequirePackage) will not work.



If the package, for some reason, needs to be loaded before the begin{document} even starts, then you can load the etoolbox package and use:



BeforeBeginEnvironment{document}{RequirePackage{xepersian}}


this will execute the RequirePackage before executing anything from the begin{document}. The effect is the same as if you had put the RequirePackage line right before begin{document} in your .tex file.






share|improve this answer


























  • What do you mean by the "proper end" of the preamble? Can you clarify?

    – Al_Fh
    18 hours ago











  • @Al_Fh I just invented that name :P I clarified the answer.

    – Phelype Oleinik
    18 hours ago











  • Thank you very much.

    – Al_Fh
    18 hours ago











  • Of course, you can always load xpersian in the preamble (before hyperref). It will not be loaded twice.

    – John Kormylo
    13 hours ago














9












9








9







You can delay the package loading using AtBeginDocument:



AtBeginDocument{RequirePackage{xepersian}}


this will put the package loading after the .aux file is read but before the “proper end” of the preamble, where all the preamble-only commands are redefined to throw an error; from this point on any usepackage (or RequirePackage) will not work.



If the package, for some reason, needs to be loaded before the begin{document} even starts, then you can load the etoolbox package and use:



BeforeBeginEnvironment{document}{RequirePackage{xepersian}}


this will execute the RequirePackage before executing anything from the begin{document}. The effect is the same as if you had put the RequirePackage line right before begin{document} in your .tex file.






share|improve this answer















You can delay the package loading using AtBeginDocument:



AtBeginDocument{RequirePackage{xepersian}}


this will put the package loading after the .aux file is read but before the “proper end” of the preamble, where all the preamble-only commands are redefined to throw an error; from this point on any usepackage (or RequirePackage) will not work.



If the package, for some reason, needs to be loaded before the begin{document} even starts, then you can load the etoolbox package and use:



BeforeBeginEnvironment{document}{RequirePackage{xepersian}}


this will execute the RequirePackage before executing anything from the begin{document}. The effect is the same as if you had put the RequirePackage line right before begin{document} in your .tex file.







share|improve this answer














share|improve this answer



share|improve this answer








edited 18 hours ago

























answered 18 hours ago









Phelype OleinikPhelype Oleinik

25k54690




25k54690













  • What do you mean by the "proper end" of the preamble? Can you clarify?

    – Al_Fh
    18 hours ago











  • @Al_Fh I just invented that name :P I clarified the answer.

    – Phelype Oleinik
    18 hours ago











  • Thank you very much.

    – Al_Fh
    18 hours ago











  • Of course, you can always load xpersian in the preamble (before hyperref). It will not be loaded twice.

    – John Kormylo
    13 hours ago



















  • What do you mean by the "proper end" of the preamble? Can you clarify?

    – Al_Fh
    18 hours ago











  • @Al_Fh I just invented that name :P I clarified the answer.

    – Phelype Oleinik
    18 hours ago











  • Thank you very much.

    – Al_Fh
    18 hours ago











  • Of course, you can always load xpersian in the preamble (before hyperref). It will not be loaded twice.

    – John Kormylo
    13 hours ago

















What do you mean by the "proper end" of the preamble? Can you clarify?

– Al_Fh
18 hours ago





What do you mean by the "proper end" of the preamble? Can you clarify?

– Al_Fh
18 hours ago













@Al_Fh I just invented that name :P I clarified the answer.

– Phelype Oleinik
18 hours ago





@Al_Fh I just invented that name :P I clarified the answer.

– Phelype Oleinik
18 hours ago













Thank you very much.

– Al_Fh
18 hours ago





Thank you very much.

– Al_Fh
18 hours ago













Of course, you can always load xpersian in the preamble (before hyperref). It will not be loaded twice.

– John Kormylo
13 hours ago





Of course, you can always load xpersian in the preamble (before hyperref). It will not be loaded twice.

– John Kormylo
13 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f484102%2fis-it-possible-to-force-a-package-to-be-called-last-in-the-entirety-of-the-latex%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Knooppunt Holsloot

Altaar (religie)

Gregoriusmis