How to use refstepcounter correctly in attempt to implement subfigures? The Next CEO of Stack...

Which one is the true statement?

Is it possible to replace duplicates of a character with one character using tr

What did we know about the Kessel run before the prequels?

Does Germany produce more waste than the US?

Bartok - Syncopation (1): Meaning of notes in between Grand Staff

Axiom Schema vs Axiom

Missile strike detection (but it's not actually a missile)

When you upcast Blindness/Deafness, do all targets suffer the same effect?

Can a Bladesinger Wizard use Bladesong with a Hand Crossbow?

How to count occurrences of text in a file?

"misplaced omit" error when >{centering} columns

Can MTA send mail via a relay without being told so?

Why do airplanes bank sharply to the right after air-to-air refueling?

Are police here, aren't itthey?

Proper way to express "He disappeared them"

The exact meaning of 'Mom made me a sandwich'

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Some questions about different axiomatic systems for neighbourhoods

RigExpert AA-35 - Interpreting The Information

Is it possible to use a NPN BJT as switch, from single power source?

How do I align (1) and (2)?

INSERT to a table from a database to other (same SQL Server) using Dynamic SQL

Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?

What steps are necessary to read a Modern SSD in Medieval Europe?



How to use refstepcounter correctly in attempt to implement subfigures?



The Next CEO of Stack OverflowHow to remove caption of some subfigures?What is going wrong with this attempt to use global?Title and caption to all SubfiguresAlign two subfigures verticallyTikz subfigures overlap4 customized subfiguresHow to correctly use newenvironmenthow to label and refer subfigures under tabular environment?Subcaption environment failed. All figures containing a subfigure crashing all of a suddenHow to use ref Inside lstlistings












1















Trying to use space on a page more economically, I developed the idea to arrange graphics as a table being part of a figure. As I still wanted to refer to individual graphics, I also wanted to have captions for each such sub-graphic.



(Only after I had problems, I realized that there does exist a similar mechanism, also named subfigure and subcaption)



(I'm no TeX expert, I only know LaTeX a bit)



The code shown below outputs the references as Text... 1 (1.2) ... 1 ...
Text... 1 (1.3) ... 1
, so the sub-caption numbers are wrong, while the main caption number is correct. The intended output is Text... 1.2a (1.2) ... 1.2b ...
Text... 1.3a (1.3) ... 1.3b
.



The captions for the example code read (numbers are correct there):



Abbildung 1.1: Caption0

Abb. 1.2a: Caption1a Abb. 1.2b: Caption1b
Abbildung 1.2: Caption1

Abb. 1.3a: Caption2a Abb. 1.3b: Caption2b
Abbildung 1.3: Caption2


So here's the input for this example (use any placeholder graphic for Platzhalter.pdf):



documentclass[a4paper,twoside]{report}
usepackage{german}
usepackage[latin1]{inputenc}
usepackage{a4}
usepackage{makeidx}
usepackage{showidx}
usepackage{amsmath}
usepackage{url}
usepackage{graphicx}
usepackage{ifthen}
%
newcounter{subfigureX}[figure]
renewcommand{thesubfigureX}{thefigurealph{subfigureX}}
newcounter{savefigure}
newcommand{gtLab}{}
newcommand{gtCap}{}
%
newenvironment{gfxTableCapLab}[4][htbp]{%
ifthenelse{equal{#4}{}}%
{renewcommand{gtLab}{}}%
{renewcommand{gtLab}{label{#4}}}%
ifthenelse{equal{#3}{}}%
{renewcommand{gtCap}{fLab}}%
{renewcommand{gtCap}{caption{gtLab{}#3}}}%
begin{figure}[#1]%
setcounter{savefigure}{value{figure}}%
stepcounter{figure}%
begin{center}%
begin{tabular}{#2}}%
{end{tabular}%
setcounter{figure}{value{savefigure}}%
gtCap%
end{center}
end{figure}%
}
%
newcommand{gLab}{}
newcommand{gCap}{}
%
newcommand{gfxCapLab}[4]{%
ifthenelse{equal{#4}{}}%
{renewcommand{gLab}{}}%
{renewcommand{gLab}{label{#4}}}%
ifthenelse{equal{#3}{}}%
{renewcommand{gCap}{gLab}}%
{renewcommand{gCap}{parnoindentgLabsubcaption{#3}}}%
begin{minipage}[t]{#1textwidth}%
{centeringincludegraphics[width=textwidth]{#2}}%
gCap%
end{minipage}%
}
%
newcommand{gfxCap}[3]{gfxCapLab{#1}{#2}{#3}{}}
%
newcommand{subcaption}[1]{%
%refstepcounter{subfigureX}
addtocounter{subfigureX}{1}%
{small Abb.~thesubfigureX: #1}%
}
begin{document}
chapter{Chap}
%
begin{figure}
Test
caption{Caption0}
end{figure}
begin{gfxTableCapLab}{lr}{Caption1}{label1}%
gfxCapLab{0.4}{Platzhalter.pdf}{Caption1a}{label1a}
&
gfxCapLab{0.4}{Platzhalter.pdf}{Caption1b}{label1b}
end{gfxTableCapLab}
%
Text...
ref{label1a} (ref{label1}) ... ref{label1b} ...

begin{gfxTableCapLab}{lr}{Caption2}{label2}%
gfxCapLab{0.4}{Platzhalter.pdf}{Caption2a}{label2a}
&
gfxCapLab{0.4}{Platzhalter.pdf}{Caption2b}{label2b}
end{gfxTableCapLab}

Text...
ref{label2a} (ref{label2}) ... ref{label2b}
end{document}


(Originally I had named my counter subfigure also, but then I discovered that a counter with such a name already exists, so I appended the X).



Preferably the answer contains an explanation why my code does not work (everything that is wrong), how to do it correctly, and (as an extra) how I could achieve the same effect using the stock subfigure and subcaption mechanisms.










share|improve this question




















  • 2





    I've never heard of steprefcounter. Did you mean to write refstepcounter?

    – Mico
    2 hours ago











  • Off-topic: The german package is obsolete. Don't load it. Instead, run usepackage[german]{babel} or, better still, usepackage[ngerman]{babel}.

    – Mico
    1 hour ago











  • @Mico: You are right (I remembered the command incorrectly): Using refstepcounter fixes the complaint, but still it does not fix the problem that the references show the wrong number. On the German package: Will do once the rest works (Thanks!).

    – U. Windl
    15 mins ago
















1















Trying to use space on a page more economically, I developed the idea to arrange graphics as a table being part of a figure. As I still wanted to refer to individual graphics, I also wanted to have captions for each such sub-graphic.



(Only after I had problems, I realized that there does exist a similar mechanism, also named subfigure and subcaption)



(I'm no TeX expert, I only know LaTeX a bit)



The code shown below outputs the references as Text... 1 (1.2) ... 1 ...
Text... 1 (1.3) ... 1
, so the sub-caption numbers are wrong, while the main caption number is correct. The intended output is Text... 1.2a (1.2) ... 1.2b ...
Text... 1.3a (1.3) ... 1.3b
.



The captions for the example code read (numbers are correct there):



Abbildung 1.1: Caption0

Abb. 1.2a: Caption1a Abb. 1.2b: Caption1b
Abbildung 1.2: Caption1

Abb. 1.3a: Caption2a Abb. 1.3b: Caption2b
Abbildung 1.3: Caption2


So here's the input for this example (use any placeholder graphic for Platzhalter.pdf):



documentclass[a4paper,twoside]{report}
usepackage{german}
usepackage[latin1]{inputenc}
usepackage{a4}
usepackage{makeidx}
usepackage{showidx}
usepackage{amsmath}
usepackage{url}
usepackage{graphicx}
usepackage{ifthen}
%
newcounter{subfigureX}[figure]
renewcommand{thesubfigureX}{thefigurealph{subfigureX}}
newcounter{savefigure}
newcommand{gtLab}{}
newcommand{gtCap}{}
%
newenvironment{gfxTableCapLab}[4][htbp]{%
ifthenelse{equal{#4}{}}%
{renewcommand{gtLab}{}}%
{renewcommand{gtLab}{label{#4}}}%
ifthenelse{equal{#3}{}}%
{renewcommand{gtCap}{fLab}}%
{renewcommand{gtCap}{caption{gtLab{}#3}}}%
begin{figure}[#1]%
setcounter{savefigure}{value{figure}}%
stepcounter{figure}%
begin{center}%
begin{tabular}{#2}}%
{end{tabular}%
setcounter{figure}{value{savefigure}}%
gtCap%
end{center}
end{figure}%
}
%
newcommand{gLab}{}
newcommand{gCap}{}
%
newcommand{gfxCapLab}[4]{%
ifthenelse{equal{#4}{}}%
{renewcommand{gLab}{}}%
{renewcommand{gLab}{label{#4}}}%
ifthenelse{equal{#3}{}}%
{renewcommand{gCap}{gLab}}%
{renewcommand{gCap}{parnoindentgLabsubcaption{#3}}}%
begin{minipage}[t]{#1textwidth}%
{centeringincludegraphics[width=textwidth]{#2}}%
gCap%
end{minipage}%
}
%
newcommand{gfxCap}[3]{gfxCapLab{#1}{#2}{#3}{}}
%
newcommand{subcaption}[1]{%
%refstepcounter{subfigureX}
addtocounter{subfigureX}{1}%
{small Abb.~thesubfigureX: #1}%
}
begin{document}
chapter{Chap}
%
begin{figure}
Test
caption{Caption0}
end{figure}
begin{gfxTableCapLab}{lr}{Caption1}{label1}%
gfxCapLab{0.4}{Platzhalter.pdf}{Caption1a}{label1a}
&
gfxCapLab{0.4}{Platzhalter.pdf}{Caption1b}{label1b}
end{gfxTableCapLab}
%
Text...
ref{label1a} (ref{label1}) ... ref{label1b} ...

begin{gfxTableCapLab}{lr}{Caption2}{label2}%
gfxCapLab{0.4}{Platzhalter.pdf}{Caption2a}{label2a}
&
gfxCapLab{0.4}{Platzhalter.pdf}{Caption2b}{label2b}
end{gfxTableCapLab}

Text...
ref{label2a} (ref{label2}) ... ref{label2b}
end{document}


(Originally I had named my counter subfigure also, but then I discovered that a counter with such a name already exists, so I appended the X).



Preferably the answer contains an explanation why my code does not work (everything that is wrong), how to do it correctly, and (as an extra) how I could achieve the same effect using the stock subfigure and subcaption mechanisms.










share|improve this question




















  • 2





    I've never heard of steprefcounter. Did you mean to write refstepcounter?

    – Mico
    2 hours ago











  • Off-topic: The german package is obsolete. Don't load it. Instead, run usepackage[german]{babel} or, better still, usepackage[ngerman]{babel}.

    – Mico
    1 hour ago











  • @Mico: You are right (I remembered the command incorrectly): Using refstepcounter fixes the complaint, but still it does not fix the problem that the references show the wrong number. On the German package: Will do once the rest works (Thanks!).

    – U. Windl
    15 mins ago














1












1








1








Trying to use space on a page more economically, I developed the idea to arrange graphics as a table being part of a figure. As I still wanted to refer to individual graphics, I also wanted to have captions for each such sub-graphic.



(Only after I had problems, I realized that there does exist a similar mechanism, also named subfigure and subcaption)



(I'm no TeX expert, I only know LaTeX a bit)



The code shown below outputs the references as Text... 1 (1.2) ... 1 ...
Text... 1 (1.3) ... 1
, so the sub-caption numbers are wrong, while the main caption number is correct. The intended output is Text... 1.2a (1.2) ... 1.2b ...
Text... 1.3a (1.3) ... 1.3b
.



The captions for the example code read (numbers are correct there):



Abbildung 1.1: Caption0

Abb. 1.2a: Caption1a Abb. 1.2b: Caption1b
Abbildung 1.2: Caption1

Abb. 1.3a: Caption2a Abb. 1.3b: Caption2b
Abbildung 1.3: Caption2


So here's the input for this example (use any placeholder graphic for Platzhalter.pdf):



documentclass[a4paper,twoside]{report}
usepackage{german}
usepackage[latin1]{inputenc}
usepackage{a4}
usepackage{makeidx}
usepackage{showidx}
usepackage{amsmath}
usepackage{url}
usepackage{graphicx}
usepackage{ifthen}
%
newcounter{subfigureX}[figure]
renewcommand{thesubfigureX}{thefigurealph{subfigureX}}
newcounter{savefigure}
newcommand{gtLab}{}
newcommand{gtCap}{}
%
newenvironment{gfxTableCapLab}[4][htbp]{%
ifthenelse{equal{#4}{}}%
{renewcommand{gtLab}{}}%
{renewcommand{gtLab}{label{#4}}}%
ifthenelse{equal{#3}{}}%
{renewcommand{gtCap}{fLab}}%
{renewcommand{gtCap}{caption{gtLab{}#3}}}%
begin{figure}[#1]%
setcounter{savefigure}{value{figure}}%
stepcounter{figure}%
begin{center}%
begin{tabular}{#2}}%
{end{tabular}%
setcounter{figure}{value{savefigure}}%
gtCap%
end{center}
end{figure}%
}
%
newcommand{gLab}{}
newcommand{gCap}{}
%
newcommand{gfxCapLab}[4]{%
ifthenelse{equal{#4}{}}%
{renewcommand{gLab}{}}%
{renewcommand{gLab}{label{#4}}}%
ifthenelse{equal{#3}{}}%
{renewcommand{gCap}{gLab}}%
{renewcommand{gCap}{parnoindentgLabsubcaption{#3}}}%
begin{minipage}[t]{#1textwidth}%
{centeringincludegraphics[width=textwidth]{#2}}%
gCap%
end{minipage}%
}
%
newcommand{gfxCap}[3]{gfxCapLab{#1}{#2}{#3}{}}
%
newcommand{subcaption}[1]{%
%refstepcounter{subfigureX}
addtocounter{subfigureX}{1}%
{small Abb.~thesubfigureX: #1}%
}
begin{document}
chapter{Chap}
%
begin{figure}
Test
caption{Caption0}
end{figure}
begin{gfxTableCapLab}{lr}{Caption1}{label1}%
gfxCapLab{0.4}{Platzhalter.pdf}{Caption1a}{label1a}
&
gfxCapLab{0.4}{Platzhalter.pdf}{Caption1b}{label1b}
end{gfxTableCapLab}
%
Text...
ref{label1a} (ref{label1}) ... ref{label1b} ...

begin{gfxTableCapLab}{lr}{Caption2}{label2}%
gfxCapLab{0.4}{Platzhalter.pdf}{Caption2a}{label2a}
&
gfxCapLab{0.4}{Platzhalter.pdf}{Caption2b}{label2b}
end{gfxTableCapLab}

Text...
ref{label2a} (ref{label2}) ... ref{label2b}
end{document}


(Originally I had named my counter subfigure also, but then I discovered that a counter with such a name already exists, so I appended the X).



Preferably the answer contains an explanation why my code does not work (everything that is wrong), how to do it correctly, and (as an extra) how I could achieve the same effect using the stock subfigure and subcaption mechanisms.










share|improve this question
















Trying to use space on a page more economically, I developed the idea to arrange graphics as a table being part of a figure. As I still wanted to refer to individual graphics, I also wanted to have captions for each such sub-graphic.



(Only after I had problems, I realized that there does exist a similar mechanism, also named subfigure and subcaption)



(I'm no TeX expert, I only know LaTeX a bit)



The code shown below outputs the references as Text... 1 (1.2) ... 1 ...
Text... 1 (1.3) ... 1
, so the sub-caption numbers are wrong, while the main caption number is correct. The intended output is Text... 1.2a (1.2) ... 1.2b ...
Text... 1.3a (1.3) ... 1.3b
.



The captions for the example code read (numbers are correct there):



Abbildung 1.1: Caption0

Abb. 1.2a: Caption1a Abb. 1.2b: Caption1b
Abbildung 1.2: Caption1

Abb. 1.3a: Caption2a Abb. 1.3b: Caption2b
Abbildung 1.3: Caption2


So here's the input for this example (use any placeholder graphic for Platzhalter.pdf):



documentclass[a4paper,twoside]{report}
usepackage{german}
usepackage[latin1]{inputenc}
usepackage{a4}
usepackage{makeidx}
usepackage{showidx}
usepackage{amsmath}
usepackage{url}
usepackage{graphicx}
usepackage{ifthen}
%
newcounter{subfigureX}[figure]
renewcommand{thesubfigureX}{thefigurealph{subfigureX}}
newcounter{savefigure}
newcommand{gtLab}{}
newcommand{gtCap}{}
%
newenvironment{gfxTableCapLab}[4][htbp]{%
ifthenelse{equal{#4}{}}%
{renewcommand{gtLab}{}}%
{renewcommand{gtLab}{label{#4}}}%
ifthenelse{equal{#3}{}}%
{renewcommand{gtCap}{fLab}}%
{renewcommand{gtCap}{caption{gtLab{}#3}}}%
begin{figure}[#1]%
setcounter{savefigure}{value{figure}}%
stepcounter{figure}%
begin{center}%
begin{tabular}{#2}}%
{end{tabular}%
setcounter{figure}{value{savefigure}}%
gtCap%
end{center}
end{figure}%
}
%
newcommand{gLab}{}
newcommand{gCap}{}
%
newcommand{gfxCapLab}[4]{%
ifthenelse{equal{#4}{}}%
{renewcommand{gLab}{}}%
{renewcommand{gLab}{label{#4}}}%
ifthenelse{equal{#3}{}}%
{renewcommand{gCap}{gLab}}%
{renewcommand{gCap}{parnoindentgLabsubcaption{#3}}}%
begin{minipage}[t]{#1textwidth}%
{centeringincludegraphics[width=textwidth]{#2}}%
gCap%
end{minipage}%
}
%
newcommand{gfxCap}[3]{gfxCapLab{#1}{#2}{#3}{}}
%
newcommand{subcaption}[1]{%
%refstepcounter{subfigureX}
addtocounter{subfigureX}{1}%
{small Abb.~thesubfigureX: #1}%
}
begin{document}
chapter{Chap}
%
begin{figure}
Test
caption{Caption0}
end{figure}
begin{gfxTableCapLab}{lr}{Caption1}{label1}%
gfxCapLab{0.4}{Platzhalter.pdf}{Caption1a}{label1a}
&
gfxCapLab{0.4}{Platzhalter.pdf}{Caption1b}{label1b}
end{gfxTableCapLab}
%
Text...
ref{label1a} (ref{label1}) ... ref{label1b} ...

begin{gfxTableCapLab}{lr}{Caption2}{label2}%
gfxCapLab{0.4}{Platzhalter.pdf}{Caption2a}{label2a}
&
gfxCapLab{0.4}{Platzhalter.pdf}{Caption2b}{label2b}
end{gfxTableCapLab}

Text...
ref{label2a} (ref{label2}) ... ref{label2b}
end{document}


(Originally I had named my counter subfigure also, but then I discovered that a counter with such a name already exists, so I appended the X).



Preferably the answer contains an explanation why my code does not work (everything that is wrong), how to do it correctly, and (as an extra) how I could achieve the same effect using the stock subfigure and subcaption mechanisms.







macros subcaption ref






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 mins ago







U. Windl

















asked 2 hours ago









U. WindlU. Windl

1477




1477








  • 2





    I've never heard of steprefcounter. Did you mean to write refstepcounter?

    – Mico
    2 hours ago











  • Off-topic: The german package is obsolete. Don't load it. Instead, run usepackage[german]{babel} or, better still, usepackage[ngerman]{babel}.

    – Mico
    1 hour ago











  • @Mico: You are right (I remembered the command incorrectly): Using refstepcounter fixes the complaint, but still it does not fix the problem that the references show the wrong number. On the German package: Will do once the rest works (Thanks!).

    – U. Windl
    15 mins ago














  • 2





    I've never heard of steprefcounter. Did you mean to write refstepcounter?

    – Mico
    2 hours ago











  • Off-topic: The german package is obsolete. Don't load it. Instead, run usepackage[german]{babel} or, better still, usepackage[ngerman]{babel}.

    – Mico
    1 hour ago











  • @Mico: You are right (I remembered the command incorrectly): Using refstepcounter fixes the complaint, but still it does not fix the problem that the references show the wrong number. On the German package: Will do once the rest works (Thanks!).

    – U. Windl
    15 mins ago








2




2





I've never heard of steprefcounter. Did you mean to write refstepcounter?

– Mico
2 hours ago





I've never heard of steprefcounter. Did you mean to write refstepcounter?

– Mico
2 hours ago













Off-topic: The german package is obsolete. Don't load it. Instead, run usepackage[german]{babel} or, better still, usepackage[ngerman]{babel}.

– Mico
1 hour ago





Off-topic: The german package is obsolete. Don't load it. Instead, run usepackage[german]{babel} or, better still, usepackage[ngerman]{babel}.

– Mico
1 hour ago













@Mico: You are right (I remembered the command incorrectly): Using refstepcounter fixes the complaint, but still it does not fix the problem that the references show the wrong number. On the German package: Will do once the rest works (Thanks!).

– U. Windl
15 mins ago





@Mico: You are right (I remembered the command incorrectly): Using refstepcounter fixes the complaint, but still it does not fix the problem that the references show the wrong number. On the German package: Will do once the rest works (Thanks!).

– U. Windl
15 mins ago










0






active

oldest

votes












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%2f482346%2fhow-to-use-refstepcounter-correctly-in-attempt-to-implement-subfigures%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f482346%2fhow-to-use-refstepcounter-correctly-in-attempt-to-implement-subfigures%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

Paper upload error, “Upload failed: The top margin is 0.715 in on page 3, which is below the required...

Emraan Hashmi Filmografia | Linki zewnętrzne | Menu nawigacyjneGulshan GroverGulshan...

How can I write this formula?newline and italics added with leqWhy does widehat behave differently if I...