Effect of `label` on caption position in new environment
I use a new environment and have tried to refer to it using the label
-ref
commands. I'm running into the problem that the label
command affects the vertical position of the caption.
The MWE is:
documentclass[a4paper]{memoir}
usepackage{lipsum}
%%% caption for new environment
makeatletter
newcommand{mycaption}[1]{%
strictpagecheckmarginpar{setlength{parindent}{1.0em}small
@afterindentfalse@afterheading {textbf{Caption themynewcount:}} #1}%
}
makeatother
%%% new environment
newcounter{mynewcount}[chapter]
renewcommand{themynewcount}{thechapter.arabic{mynewcount}}
newenvironment{mynewenv}[1]{%
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#1}%
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
begin{document}
chapter{Chapter}
lipsum[1]
begin{mynewenv}{Caption}
label{test} % <<< label
lipsum[2]
end{mynewenv}
ref{test} % <<< refer to label
end{document}
Without the label
and ref
commands, the caption is properly aligned with the top of the contents of the environment:
With them, however, the caption is shifted up:
How can I fix this?
formatting environments minipage
add a comment |
I use a new environment and have tried to refer to it using the label
-ref
commands. I'm running into the problem that the label
command affects the vertical position of the caption.
The MWE is:
documentclass[a4paper]{memoir}
usepackage{lipsum}
%%% caption for new environment
makeatletter
newcommand{mycaption}[1]{%
strictpagecheckmarginpar{setlength{parindent}{1.0em}small
@afterindentfalse@afterheading {textbf{Caption themynewcount:}} #1}%
}
makeatother
%%% new environment
newcounter{mynewcount}[chapter]
renewcommand{themynewcount}{thechapter.arabic{mynewcount}}
newenvironment{mynewenv}[1]{%
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#1}%
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
begin{document}
chapter{Chapter}
lipsum[1]
begin{mynewenv}{Caption}
label{test} % <<< label
lipsum[2]
end{mynewenv}
ref{test} % <<< refer to label
end{document}
Without the label
and ref
commands, the caption is properly aligned with the top of the contents of the environment:
With them, however, the caption is shifted up:
How can I fix this?
formatting environments minipage
add a comment |
I use a new environment and have tried to refer to it using the label
-ref
commands. I'm running into the problem that the label
command affects the vertical position of the caption.
The MWE is:
documentclass[a4paper]{memoir}
usepackage{lipsum}
%%% caption for new environment
makeatletter
newcommand{mycaption}[1]{%
strictpagecheckmarginpar{setlength{parindent}{1.0em}small
@afterindentfalse@afterheading {textbf{Caption themynewcount:}} #1}%
}
makeatother
%%% new environment
newcounter{mynewcount}[chapter]
renewcommand{themynewcount}{thechapter.arabic{mynewcount}}
newenvironment{mynewenv}[1]{%
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#1}%
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
begin{document}
chapter{Chapter}
lipsum[1]
begin{mynewenv}{Caption}
label{test} % <<< label
lipsum[2]
end{mynewenv}
ref{test} % <<< refer to label
end{document}
Without the label
and ref
commands, the caption is properly aligned with the top of the contents of the environment:
With them, however, the caption is shifted up:
How can I fix this?
formatting environments minipage
I use a new environment and have tried to refer to it using the label
-ref
commands. I'm running into the problem that the label
command affects the vertical position of the caption.
The MWE is:
documentclass[a4paper]{memoir}
usepackage{lipsum}
%%% caption for new environment
makeatletter
newcommand{mycaption}[1]{%
strictpagecheckmarginpar{setlength{parindent}{1.0em}small
@afterindentfalse@afterheading {textbf{Caption themynewcount:}} #1}%
}
makeatother
%%% new environment
newcounter{mynewcount}[chapter]
renewcommand{themynewcount}{thechapter.arabic{mynewcount}}
newenvironment{mynewenv}[1]{%
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#1}%
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
begin{document}
chapter{Chapter}
lipsum[1]
begin{mynewenv}{Caption}
label{test} % <<< label
lipsum[2]
end{mynewenv}
ref{test} % <<< refer to label
end{document}
Without the label
and ref
commands, the caption is properly aligned with the top of the contents of the environment:
With them, however, the caption is shifted up:
How can I fix this?
formatting environments minipage
formatting environments minipage
asked 26 mins ago
user1362373
8711027
8711027
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I would change the mynewenv
environment definition to have an optional argument to be used within label
, as shown below:
newenvironment{mynewenv}[2]{% <-- here
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#2}label{#1}% <-- here
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
Then, you simply pass the label
as option, like:
begin{mynewenv}[test]{Caption}
lipsum[2]
end{mynewenv}
As we can see in ref{test}...
Or without the option:
begin{mynewenv}{Caption}
lipsum[2]
end{mynewenv}
If the optional argument is not used,label{}
will occur, which is no problem, but awful, but you will getmultiply defined labels
warnings when using the environment twice or more times without setting the optional argument.
– Christian Hupfer
34 secs ago
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467684%2feffect-of-label-on-caption-position-in-new-environment%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
I would change the mynewenv
environment definition to have an optional argument to be used within label
, as shown below:
newenvironment{mynewenv}[2]{% <-- here
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#2}label{#1}% <-- here
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
Then, you simply pass the label
as option, like:
begin{mynewenv}[test]{Caption}
lipsum[2]
end{mynewenv}
As we can see in ref{test}...
Or without the option:
begin{mynewenv}{Caption}
lipsum[2]
end{mynewenv}
If the optional argument is not used,label{}
will occur, which is no problem, but awful, but you will getmultiply defined labels
warnings when using the environment twice or more times without setting the optional argument.
– Christian Hupfer
34 secs ago
add a comment |
I would change the mynewenv
environment definition to have an optional argument to be used within label
, as shown below:
newenvironment{mynewenv}[2]{% <-- here
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#2}label{#1}% <-- here
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
Then, you simply pass the label
as option, like:
begin{mynewenv}[test]{Caption}
lipsum[2]
end{mynewenv}
As we can see in ref{test}...
Or without the option:
begin{mynewenv}{Caption}
lipsum[2]
end{mynewenv}
If the optional argument is not used,label{}
will occur, which is no problem, but awful, but you will getmultiply defined labels
warnings when using the environment twice or more times without setting the optional argument.
– Christian Hupfer
34 secs ago
add a comment |
I would change the mynewenv
environment definition to have an optional argument to be used within label
, as shown below:
newenvironment{mynewenv}[2]{% <-- here
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#2}label{#1}% <-- here
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
Then, you simply pass the label
as option, like:
begin{mynewenv}[test]{Caption}
lipsum[2]
end{mynewenv}
As we can see in ref{test}...
Or without the option:
begin{mynewenv}{Caption}
lipsum[2]
end{mynewenv}
I would change the mynewenv
environment definition to have an optional argument to be used within label
, as shown below:
newenvironment{mynewenv}[2]{% <-- here
refstepcounter{mynewcount}%
vspace{2abovedisplayskip}%
mycaption{#2}label{#1}% <-- here
vspace{-abovedisplayskip}
noindentbegin{minipage}[t]{textwidth}%
}{end{minipage}vspace{belowdisplayskip}}
Then, you simply pass the label
as option, like:
begin{mynewenv}[test]{Caption}
lipsum[2]
end{mynewenv}
As we can see in ref{test}...
Or without the option:
begin{mynewenv}{Caption}
lipsum[2]
end{mynewenv}
answered 11 mins ago
Sigur
23.9k355137
23.9k355137
If the optional argument is not used,label{}
will occur, which is no problem, but awful, but you will getmultiply defined labels
warnings when using the environment twice or more times without setting the optional argument.
– Christian Hupfer
34 secs ago
add a comment |
If the optional argument is not used,label{}
will occur, which is no problem, but awful, but you will getmultiply defined labels
warnings when using the environment twice or more times without setting the optional argument.
– Christian Hupfer
34 secs ago
If the optional argument is not used,
label{}
will occur, which is no problem, but awful, but you will get multiply defined labels
warnings when using the environment twice or more times without setting the optional argument.– Christian Hupfer
34 secs ago
If the optional argument is not used,
label{}
will occur, which is no problem, but awful, but you will get multiply defined labels
warnings when using the environment twice or more times without setting the optional argument.– Christian Hupfer
34 secs ago
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f467684%2feffect-of-label-on-caption-position-in-new-environment%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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