How to define a new command with counterHyperlinks with mouseover for link to bibliographyHow to link to...

Skis versus snow shoes - when to choose which for travelling the backcountry?

Equivalent to "source" in OpenBSD?

How to count words in a line

I can't die. Who am I?

If a druid in Wild Shape swallows a creature whole, then turns back to her normal form, what happens?

Creature spells vs. ability to convert a permanent into a creature

Why proton concentration is divided by 10⁻⁷?

Understanding Kramnik's play in game 1 of Candidates 2018

When does inspiration across artforms become plagiarism

g++ and clang++ different behaviour with recursive initialization of a static member

What prevents the construction of a CPU with all necessary memory represented in registers?

What is the wife of a henpecked husband called?

What can I substitute for soda pop in a sweet pork recipe?

How to properly claim credit for peer review?

How to speed up a process

What's the difference between a cart and a wagon?

Are small insurances worth it

Can you 'upgrade' leather armor to studded leather armor without purchasing the new armor directly?

What is better: yes / no radio, or simple checkbox?

Linear regression when Y is bounded and discrete

How to add multiple differently colored borders around a node?

How do I implement simple JS code to deploy a compiled smart contract to ganache-cli?

What are these green text/line displays shown during the livestream of Crew Dragon's approach to dock with the ISS?

Which aircraft had such a luxurious-looking navigator's station?



How to define a new command with counter


Hyperlinks with mouseover for link to bibliographyHow to link to local pdf file with full pathHow to remove the hyperlink from homepage{}How to change moderncv social[linkedin] from http to https?Acronym hyperlink with special color only at first occurencehyperlink with % in it?Problem with Hyperref. Only shows text and not any clickable linkIEEEtran - How to include ORCID in TeX/PDF with PdfLatexSet the print flag on links with hyperref to preserve them with Ghostscript >= 9.25How to remove hyperlinks of citations (of publications) in LaTeX?













0















I am currently writing a report where I use hyperlink, as an example href{run:./Annex/MyTestResult.pdf}{Annex 4}.
It works pretty fine.



However, I would like to add a counter for Annex numbering.
Is there a way to make this easier for example by using newcommand? If so, how can I add a counter and use href command?










share|improve this question




















  • 1





    newcounter{annexcntr}newcommand{annexref}[1]{refstepcounter{annexcntr}href{#1}{Annex~ theannexctr}, most likely? annexref{run:./Annex/MyTestResult.pdf} should work then

    – Christian Hupfer
    Feb 28 at 13:41


















0















I am currently writing a report where I use hyperlink, as an example href{run:./Annex/MyTestResult.pdf}{Annex 4}.
It works pretty fine.



However, I would like to add a counter for Annex numbering.
Is there a way to make this easier for example by using newcommand? If so, how can I add a counter and use href command?










share|improve this question




















  • 1





    newcounter{annexcntr}newcommand{annexref}[1]{refstepcounter{annexcntr}href{#1}{Annex~ theannexctr}, most likely? annexref{run:./Annex/MyTestResult.pdf} should work then

    – Christian Hupfer
    Feb 28 at 13:41
















0












0








0








I am currently writing a report where I use hyperlink, as an example href{run:./Annex/MyTestResult.pdf}{Annex 4}.
It works pretty fine.



However, I would like to add a counter for Annex numbering.
Is there a way to make this easier for example by using newcommand? If so, how can I add a counter and use href command?










share|improve this question
















I am currently writing a report where I use hyperlink, as an example href{run:./Annex/MyTestResult.pdf}{Annex 4}.
It works pretty fine.



However, I would like to add a counter for Annex numbering.
Is there a way to make this easier for example by using newcommand? If so, how can I add a counter and use href command?







hyperlink






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 15 hours ago









Christian Hupfer

151k15199395




151k15199395










asked Feb 28 at 13:31









AirthanAirthan

555




555








  • 1





    newcounter{annexcntr}newcommand{annexref}[1]{refstepcounter{annexcntr}href{#1}{Annex~ theannexctr}, most likely? annexref{run:./Annex/MyTestResult.pdf} should work then

    – Christian Hupfer
    Feb 28 at 13:41
















  • 1





    newcounter{annexcntr}newcommand{annexref}[1]{refstepcounter{annexcntr}href{#1}{Annex~ theannexctr}, most likely? annexref{run:./Annex/MyTestResult.pdf} should work then

    – Christian Hupfer
    Feb 28 at 13:41










1




1





newcounter{annexcntr}newcommand{annexref}[1]{refstepcounter{annexcntr}href{#1}{Annex~ theannexctr}, most likely? annexref{run:./Annex/MyTestResult.pdf} should work then

– Christian Hupfer
Feb 28 at 13:41







newcounter{annexcntr}newcommand{annexref}[1]{refstepcounter{annexcntr}href{#1}{Annex~ theannexctr}, most likely? annexref{run:./Annex/MyTestResult.pdf} should work then

– Christian Hupfer
Feb 28 at 13:41












1 Answer
1






active

oldest

votes


















3














I'm no really sure what's the expected output. Following Christian Hupfer's lead, I reordered and cleaned up the code thus:



documentclass{article}
usepackage{hyperref}
newcounter{annexcntr}

newcommand*{annexref}[1]{%
stepcounter{annexcntr}%
href{#1}{Annex~arabic{annexcntr}}%
}

begin{document}
annexref{run:./Annex/MyTestResult.pdf}
annexref{run:./Annex/MyTestResult.pdf}
end{document}


Which renders as:



enter image description here






share|improve this answer
























  • What does clean up and reorder mean in conjunction with my comment, apart from that it was a comment only, lacking display facilities and the fact that I've forgotten a closing } accidentally?

    – Christian Hupfer
    Feb 28 at 17:30











  • I took your comment and changed the theannexctr to arabic{annexctr}, and created a MWE. I also gave you credit for it. Feel free to post is as an answer, if you wish to.

    – NVaughan
    Mar 1 at 14:52













  • theannexcntr is the preferred way to display the counter value according to requested format. It falls back to arabic{annexctr} if not specified otherwise... Taking comments of other users is not the way to start, actually.

    – Christian Hupfer
    yesterday













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%2f477140%2fhow-to-define-a-new-command-with-counter%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









3














I'm no really sure what's the expected output. Following Christian Hupfer's lead, I reordered and cleaned up the code thus:



documentclass{article}
usepackage{hyperref}
newcounter{annexcntr}

newcommand*{annexref}[1]{%
stepcounter{annexcntr}%
href{#1}{Annex~arabic{annexcntr}}%
}

begin{document}
annexref{run:./Annex/MyTestResult.pdf}
annexref{run:./Annex/MyTestResult.pdf}
end{document}


Which renders as:



enter image description here






share|improve this answer
























  • What does clean up and reorder mean in conjunction with my comment, apart from that it was a comment only, lacking display facilities and the fact that I've forgotten a closing } accidentally?

    – Christian Hupfer
    Feb 28 at 17:30











  • I took your comment and changed the theannexctr to arabic{annexctr}, and created a MWE. I also gave you credit for it. Feel free to post is as an answer, if you wish to.

    – NVaughan
    Mar 1 at 14:52













  • theannexcntr is the preferred way to display the counter value according to requested format. It falls back to arabic{annexctr} if not specified otherwise... Taking comments of other users is not the way to start, actually.

    – Christian Hupfer
    yesterday


















3














I'm no really sure what's the expected output. Following Christian Hupfer's lead, I reordered and cleaned up the code thus:



documentclass{article}
usepackage{hyperref}
newcounter{annexcntr}

newcommand*{annexref}[1]{%
stepcounter{annexcntr}%
href{#1}{Annex~arabic{annexcntr}}%
}

begin{document}
annexref{run:./Annex/MyTestResult.pdf}
annexref{run:./Annex/MyTestResult.pdf}
end{document}


Which renders as:



enter image description here






share|improve this answer
























  • What does clean up and reorder mean in conjunction with my comment, apart from that it was a comment only, lacking display facilities and the fact that I've forgotten a closing } accidentally?

    – Christian Hupfer
    Feb 28 at 17:30











  • I took your comment and changed the theannexctr to arabic{annexctr}, and created a MWE. I also gave you credit for it. Feel free to post is as an answer, if you wish to.

    – NVaughan
    Mar 1 at 14:52













  • theannexcntr is the preferred way to display the counter value according to requested format. It falls back to arabic{annexctr} if not specified otherwise... Taking comments of other users is not the way to start, actually.

    – Christian Hupfer
    yesterday
















3












3








3







I'm no really sure what's the expected output. Following Christian Hupfer's lead, I reordered and cleaned up the code thus:



documentclass{article}
usepackage{hyperref}
newcounter{annexcntr}

newcommand*{annexref}[1]{%
stepcounter{annexcntr}%
href{#1}{Annex~arabic{annexcntr}}%
}

begin{document}
annexref{run:./Annex/MyTestResult.pdf}
annexref{run:./Annex/MyTestResult.pdf}
end{document}


Which renders as:



enter image description here






share|improve this answer













I'm no really sure what's the expected output. Following Christian Hupfer's lead, I reordered and cleaned up the code thus:



documentclass{article}
usepackage{hyperref}
newcounter{annexcntr}

newcommand*{annexref}[1]{%
stepcounter{annexcntr}%
href{#1}{Annex~arabic{annexcntr}}%
}

begin{document}
annexref{run:./Annex/MyTestResult.pdf}
annexref{run:./Annex/MyTestResult.pdf}
end{document}


Which renders as:



enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 28 at 14:04









NVaughanNVaughan

4,5001738




4,5001738













  • What does clean up and reorder mean in conjunction with my comment, apart from that it was a comment only, lacking display facilities and the fact that I've forgotten a closing } accidentally?

    – Christian Hupfer
    Feb 28 at 17:30











  • I took your comment and changed the theannexctr to arabic{annexctr}, and created a MWE. I also gave you credit for it. Feel free to post is as an answer, if you wish to.

    – NVaughan
    Mar 1 at 14:52













  • theannexcntr is the preferred way to display the counter value according to requested format. It falls back to arabic{annexctr} if not specified otherwise... Taking comments of other users is not the way to start, actually.

    – Christian Hupfer
    yesterday





















  • What does clean up and reorder mean in conjunction with my comment, apart from that it was a comment only, lacking display facilities and the fact that I've forgotten a closing } accidentally?

    – Christian Hupfer
    Feb 28 at 17:30











  • I took your comment and changed the theannexctr to arabic{annexctr}, and created a MWE. I also gave you credit for it. Feel free to post is as an answer, if you wish to.

    – NVaughan
    Mar 1 at 14:52













  • theannexcntr is the preferred way to display the counter value according to requested format. It falls back to arabic{annexctr} if not specified otherwise... Taking comments of other users is not the way to start, actually.

    – Christian Hupfer
    yesterday



















What does clean up and reorder mean in conjunction with my comment, apart from that it was a comment only, lacking display facilities and the fact that I've forgotten a closing } accidentally?

– Christian Hupfer
Feb 28 at 17:30





What does clean up and reorder mean in conjunction with my comment, apart from that it was a comment only, lacking display facilities and the fact that I've forgotten a closing } accidentally?

– Christian Hupfer
Feb 28 at 17:30













I took your comment and changed the theannexctr to arabic{annexctr}, and created a MWE. I also gave you credit for it. Feel free to post is as an answer, if you wish to.

– NVaughan
Mar 1 at 14:52







I took your comment and changed the theannexctr to arabic{annexctr}, and created a MWE. I also gave you credit for it. Feel free to post is as an answer, if you wish to.

– NVaughan
Mar 1 at 14:52















theannexcntr is the preferred way to display the counter value according to requested format. It falls back to arabic{annexctr} if not specified otherwise... Taking comments of other users is not the way to start, actually.

– Christian Hupfer
yesterday







theannexcntr is the preferred way to display the counter value according to requested format. It falls back to arabic{annexctr} if not specified otherwise... Taking comments of other users is not the way to start, actually.

– Christian Hupfer
yesterday




















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%2f477140%2fhow-to-define-a-new-command-with-counter%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

El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

Castillo d'Acher Características Menú de navegación

Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...