Defining a new environment












2














I have asked before, but I never got the answer I was looking for. (old question is here: Defining a new figure environment)



As the title suggests I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command.



The example is the same as the old question: How can I define a new environment, that makes 2 images stand side by side



This is what I have tried without it working.



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage{caption}
usepackage{graphicx,caption}
usepackage{float}

newenvironment{sidebyside}[6]{
begin{figure}[H]
centering
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}
%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}
}


The sole reason I want it as an environment, is because I'm working with people who doesn't understand LaTeX coding, so I need to make it as easy for them as possible.



Thank you, in advance.



/Lau



Edit for clarification:



When the user types "begin{sidebyside}" and presses enter, (s)he should see the following code pop up:



begin{sidebyside}
begin{figure}[H]
centering
begin{subfigure}[b]{0.49textwidth}
includegraphics{}
caption{}
end{subfigure}
%
begin{subfigure}[b]{0.49textwidth}
includegraphics{}
caption{}
end{subfigure}
caption{protectraggedright }
label{}
end{figure}
end{sidebyside}


Edit 2:



Apparantly my question is still hard to understand. So I've recorded what I'd want to happen here: https://youtu.be/vEBT6Z5TwJQ










share|improve this question
























  • Off-topic: Don't you think you might be better of defining a template/snippet with that structure? Good editors usually support some feature of the kind.
    – gusbrs
    Dec 2 '18 at 14:05










  • How do you expect the user interface to be? You have written it in a way that would fit into a command. I can't imagine who you would want this to look as environment.
    – TeXnician
    Dec 2 '18 at 14:09










  • @gusbrs If that makes the code "pop-up" like it does when begin{figure} +enter is written, then yes, it might be the solution I'm looking for.
    – L. Nielsen
    Dec 2 '18 at 14:21










  • @TeXnician I wouldn't say I'm new to LaTeX, but I still don't know a lot of things, for example what you mean when you say "user interface". Maybe I need to clarify in my post that I want it to "act" in the same way as the basic begin{figure}-environment when I write begin{sidebyside} +[Enter] I don't know how else to describe it.
    – L. Nielsen
    Dec 2 '18 at 14:24










  • With user interface I do not refer to a TeXnical term, but to a general technical one. What is the user expected to do/see? What should be the content of begin{sidebyside}...end{sidebyside}? In my view, the usual setup with so many fixed variables would be a command…
    – TeXnician
    Dec 2 '18 at 14:31
















2














I have asked before, but I never got the answer I was looking for. (old question is here: Defining a new figure environment)



As the title suggests I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command.



The example is the same as the old question: How can I define a new environment, that makes 2 images stand side by side



This is what I have tried without it working.



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage{caption}
usepackage{graphicx,caption}
usepackage{float}

newenvironment{sidebyside}[6]{
begin{figure}[H]
centering
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}
%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}
}


The sole reason I want it as an environment, is because I'm working with people who doesn't understand LaTeX coding, so I need to make it as easy for them as possible.



Thank you, in advance.



/Lau



Edit for clarification:



When the user types "begin{sidebyside}" and presses enter, (s)he should see the following code pop up:



begin{sidebyside}
begin{figure}[H]
centering
begin{subfigure}[b]{0.49textwidth}
includegraphics{}
caption{}
end{subfigure}
%
begin{subfigure}[b]{0.49textwidth}
includegraphics{}
caption{}
end{subfigure}
caption{protectraggedright }
label{}
end{figure}
end{sidebyside}


Edit 2:



Apparantly my question is still hard to understand. So I've recorded what I'd want to happen here: https://youtu.be/vEBT6Z5TwJQ










share|improve this question
























  • Off-topic: Don't you think you might be better of defining a template/snippet with that structure? Good editors usually support some feature of the kind.
    – gusbrs
    Dec 2 '18 at 14:05










  • How do you expect the user interface to be? You have written it in a way that would fit into a command. I can't imagine who you would want this to look as environment.
    – TeXnician
    Dec 2 '18 at 14:09










  • @gusbrs If that makes the code "pop-up" like it does when begin{figure} +enter is written, then yes, it might be the solution I'm looking for.
    – L. Nielsen
    Dec 2 '18 at 14:21










  • @TeXnician I wouldn't say I'm new to LaTeX, but I still don't know a lot of things, for example what you mean when you say "user interface". Maybe I need to clarify in my post that I want it to "act" in the same way as the basic begin{figure}-environment when I write begin{sidebyside} +[Enter] I don't know how else to describe it.
    – L. Nielsen
    Dec 2 '18 at 14:24










  • With user interface I do not refer to a TeXnical term, but to a general technical one. What is the user expected to do/see? What should be the content of begin{sidebyside}...end{sidebyside}? In my view, the usual setup with so many fixed variables would be a command…
    – TeXnician
    Dec 2 '18 at 14:31














2












2








2







I have asked before, but I never got the answer I was looking for. (old question is here: Defining a new figure environment)



As the title suggests I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command.



The example is the same as the old question: How can I define a new environment, that makes 2 images stand side by side



This is what I have tried without it working.



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage{caption}
usepackage{graphicx,caption}
usepackage{float}

newenvironment{sidebyside}[6]{
begin{figure}[H]
centering
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}
%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}
}


The sole reason I want it as an environment, is because I'm working with people who doesn't understand LaTeX coding, so I need to make it as easy for them as possible.



Thank you, in advance.



/Lau



Edit for clarification:



When the user types "begin{sidebyside}" and presses enter, (s)he should see the following code pop up:



begin{sidebyside}
begin{figure}[H]
centering
begin{subfigure}[b]{0.49textwidth}
includegraphics{}
caption{}
end{subfigure}
%
begin{subfigure}[b]{0.49textwidth}
includegraphics{}
caption{}
end{subfigure}
caption{protectraggedright }
label{}
end{figure}
end{sidebyside}


Edit 2:



Apparantly my question is still hard to understand. So I've recorded what I'd want to happen here: https://youtu.be/vEBT6Z5TwJQ










share|improve this question















I have asked before, but I never got the answer I was looking for. (old question is here: Defining a new figure environment)



As the title suggests I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command.



The example is the same as the old question: How can I define a new environment, that makes 2 images stand side by side



This is what I have tried without it working.



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage{caption}
usepackage{graphicx,caption}
usepackage{float}

newenvironment{sidebyside}[6]{
begin{figure}[H]
centering
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}
%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}
}


The sole reason I want it as an environment, is because I'm working with people who doesn't understand LaTeX coding, so I need to make it as easy for them as possible.



Thank you, in advance.



/Lau



Edit for clarification:



When the user types "begin{sidebyside}" and presses enter, (s)he should see the following code pop up:



begin{sidebyside}
begin{figure}[H]
centering
begin{subfigure}[b]{0.49textwidth}
includegraphics{}
caption{}
end{subfigure}
%
begin{subfigure}[b]{0.49textwidth}
includegraphics{}
caption{}
end{subfigure}
caption{protectraggedright }
label{}
end{figure}
end{sidebyside}


Edit 2:



Apparantly my question is still hard to understand. So I've recorded what I'd want to happen here: https://youtu.be/vEBT6Z5TwJQ







floats environments






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 2 '18 at 16:38

























asked Dec 2 '18 at 13:57









L. Nielsen

376




376












  • Off-topic: Don't you think you might be better of defining a template/snippet with that structure? Good editors usually support some feature of the kind.
    – gusbrs
    Dec 2 '18 at 14:05










  • How do you expect the user interface to be? You have written it in a way that would fit into a command. I can't imagine who you would want this to look as environment.
    – TeXnician
    Dec 2 '18 at 14:09










  • @gusbrs If that makes the code "pop-up" like it does when begin{figure} +enter is written, then yes, it might be the solution I'm looking for.
    – L. Nielsen
    Dec 2 '18 at 14:21










  • @TeXnician I wouldn't say I'm new to LaTeX, but I still don't know a lot of things, for example what you mean when you say "user interface". Maybe I need to clarify in my post that I want it to "act" in the same way as the basic begin{figure}-environment when I write begin{sidebyside} +[Enter] I don't know how else to describe it.
    – L. Nielsen
    Dec 2 '18 at 14:24










  • With user interface I do not refer to a TeXnical term, but to a general technical one. What is the user expected to do/see? What should be the content of begin{sidebyside}...end{sidebyside}? In my view, the usual setup with so many fixed variables would be a command…
    – TeXnician
    Dec 2 '18 at 14:31


















  • Off-topic: Don't you think you might be better of defining a template/snippet with that structure? Good editors usually support some feature of the kind.
    – gusbrs
    Dec 2 '18 at 14:05










  • How do you expect the user interface to be? You have written it in a way that would fit into a command. I can't imagine who you would want this to look as environment.
    – TeXnician
    Dec 2 '18 at 14:09










  • @gusbrs If that makes the code "pop-up" like it does when begin{figure} +enter is written, then yes, it might be the solution I'm looking for.
    – L. Nielsen
    Dec 2 '18 at 14:21










  • @TeXnician I wouldn't say I'm new to LaTeX, but I still don't know a lot of things, for example what you mean when you say "user interface". Maybe I need to clarify in my post that I want it to "act" in the same way as the basic begin{figure}-environment when I write begin{sidebyside} +[Enter] I don't know how else to describe it.
    – L. Nielsen
    Dec 2 '18 at 14:24










  • With user interface I do not refer to a TeXnical term, but to a general technical one. What is the user expected to do/see? What should be the content of begin{sidebyside}...end{sidebyside}? In my view, the usual setup with so many fixed variables would be a command…
    – TeXnician
    Dec 2 '18 at 14:31
















Off-topic: Don't you think you might be better of defining a template/snippet with that structure? Good editors usually support some feature of the kind.
– gusbrs
Dec 2 '18 at 14:05




Off-topic: Don't you think you might be better of defining a template/snippet with that structure? Good editors usually support some feature of the kind.
– gusbrs
Dec 2 '18 at 14:05












How do you expect the user interface to be? You have written it in a way that would fit into a command. I can't imagine who you would want this to look as environment.
– TeXnician
Dec 2 '18 at 14:09




How do you expect the user interface to be? You have written it in a way that would fit into a command. I can't imagine who you would want this to look as environment.
– TeXnician
Dec 2 '18 at 14:09












@gusbrs If that makes the code "pop-up" like it does when begin{figure} +enter is written, then yes, it might be the solution I'm looking for.
– L. Nielsen
Dec 2 '18 at 14:21




@gusbrs If that makes the code "pop-up" like it does when begin{figure} +enter is written, then yes, it might be the solution I'm looking for.
– L. Nielsen
Dec 2 '18 at 14:21












@TeXnician I wouldn't say I'm new to LaTeX, but I still don't know a lot of things, for example what you mean when you say "user interface". Maybe I need to clarify in my post that I want it to "act" in the same way as the basic begin{figure}-environment when I write begin{sidebyside} +[Enter] I don't know how else to describe it.
– L. Nielsen
Dec 2 '18 at 14:24




@TeXnician I wouldn't say I'm new to LaTeX, but I still don't know a lot of things, for example what you mean when you say "user interface". Maybe I need to clarify in my post that I want it to "act" in the same way as the basic begin{figure}-environment when I write begin{sidebyside} +[Enter] I don't know how else to describe it.
– L. Nielsen
Dec 2 '18 at 14:24












With user interface I do not refer to a TeXnical term, but to a general technical one. What is the user expected to do/see? What should be the content of begin{sidebyside}...end{sidebyside}? In my view, the usual setup with so many fixed variables would be a command…
– TeXnician
Dec 2 '18 at 14:31




With user interface I do not refer to a TeXnical term, but to a general technical one. What is the user expected to do/see? What should be the content of begin{sidebyside}...end{sidebyside}? In my view, the usual setup with so many fixed variables would be a command…
– TeXnician
Dec 2 '18 at 14:31










1 Answer
1






active

oldest

votes


















7














Here's an environment-based solution.



enter image description here



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage[demo]{graphicx} % remove 'demo' option in real document
usepackage{subcaption,float}

newenvironment{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}}{%
end{figure}}

begin{document}
setcounter{chapter}{2} % just for this example
begin{sidebyside}%
{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}
end{sidebyside}
end{document}




That said, I agree with @TeXnician that a macro-based solution seems far more natural and at least as straightforward to implement. First the command definition:



newcommand{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}}


Second, a way to call the command:



sidebyside{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}





share|improve this answer





















  • This works fine for me, because I know how to use it, but my colleagues doesn't know what to write in the different { }, no matter how many times I tell them. Do you any way to make it like I've described in my post-edit?
    – L. Nielsen
    Dec 2 '18 at 15:03








  • 2




    @L.Nielsen - Your follow-up question would appear to be highly editor-dependent. I'm afraid I am utterly unfamiliar with Overleaf. Maybe post a query on the Overleaf help site for advice on generating a pop-up window?
    – Mico
    Dec 2 '18 at 15:10












  • Ah, I see my question is hard to understand still... I'm not talking about pop-up windows :/..... You know how the begin{figure} environment folds out? I have made a video, showing what I want to happen: youtu.be/vEBT6Z5TwJQ . Please read the description in the video, as I can't make annotations anymore...
    – L. Nielsen
    Dec 2 '18 at 16:32










  • @L.Nielsen - Your original query was, "I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command". That's the query I tried to answer. This site really only works well if each query has one, and only one, substantive question. If you have a substantially new follow-up question, you should post a new, separate query. Finally, I continue to be utterly unfamiliar with Overleaf. If you choose to post a new query, you should make clear that any answers must be Overleaf-specific.
    – Mico
    Dec 2 '18 at 16:45












  • Yes, and I appreciate the answer and it works. Thank you. I will be more specific in the future.
    – L. Nielsen
    Dec 2 '18 at 16:51











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%2f462814%2fdefining-a-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









7














Here's an environment-based solution.



enter image description here



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage[demo]{graphicx} % remove 'demo' option in real document
usepackage{subcaption,float}

newenvironment{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}}{%
end{figure}}

begin{document}
setcounter{chapter}{2} % just for this example
begin{sidebyside}%
{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}
end{sidebyside}
end{document}




That said, I agree with @TeXnician that a macro-based solution seems far more natural and at least as straightforward to implement. First the command definition:



newcommand{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}}


Second, a way to call the command:



sidebyside{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}





share|improve this answer





















  • This works fine for me, because I know how to use it, but my colleagues doesn't know what to write in the different { }, no matter how many times I tell them. Do you any way to make it like I've described in my post-edit?
    – L. Nielsen
    Dec 2 '18 at 15:03








  • 2




    @L.Nielsen - Your follow-up question would appear to be highly editor-dependent. I'm afraid I am utterly unfamiliar with Overleaf. Maybe post a query on the Overleaf help site for advice on generating a pop-up window?
    – Mico
    Dec 2 '18 at 15:10












  • Ah, I see my question is hard to understand still... I'm not talking about pop-up windows :/..... You know how the begin{figure} environment folds out? I have made a video, showing what I want to happen: youtu.be/vEBT6Z5TwJQ . Please read the description in the video, as I can't make annotations anymore...
    – L. Nielsen
    Dec 2 '18 at 16:32










  • @L.Nielsen - Your original query was, "I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command". That's the query I tried to answer. This site really only works well if each query has one, and only one, substantive question. If you have a substantially new follow-up question, you should post a new, separate query. Finally, I continue to be utterly unfamiliar with Overleaf. If you choose to post a new query, you should make clear that any answers must be Overleaf-specific.
    – Mico
    Dec 2 '18 at 16:45












  • Yes, and I appreciate the answer and it works. Thank you. I will be more specific in the future.
    – L. Nielsen
    Dec 2 '18 at 16:51
















7














Here's an environment-based solution.



enter image description here



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage[demo]{graphicx} % remove 'demo' option in real document
usepackage{subcaption,float}

newenvironment{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}}{%
end{figure}}

begin{document}
setcounter{chapter}{2} % just for this example
begin{sidebyside}%
{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}
end{sidebyside}
end{document}




That said, I agree with @TeXnician that a macro-based solution seems far more natural and at least as straightforward to implement. First the command definition:



newcommand{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}}


Second, a way to call the command:



sidebyside{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}





share|improve this answer





















  • This works fine for me, because I know how to use it, but my colleagues doesn't know what to write in the different { }, no matter how many times I tell them. Do you any way to make it like I've described in my post-edit?
    – L. Nielsen
    Dec 2 '18 at 15:03








  • 2




    @L.Nielsen - Your follow-up question would appear to be highly editor-dependent. I'm afraid I am utterly unfamiliar with Overleaf. Maybe post a query on the Overleaf help site for advice on generating a pop-up window?
    – Mico
    Dec 2 '18 at 15:10












  • Ah, I see my question is hard to understand still... I'm not talking about pop-up windows :/..... You know how the begin{figure} environment folds out? I have made a video, showing what I want to happen: youtu.be/vEBT6Z5TwJQ . Please read the description in the video, as I can't make annotations anymore...
    – L. Nielsen
    Dec 2 '18 at 16:32










  • @L.Nielsen - Your original query was, "I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command". That's the query I tried to answer. This site really only works well if each query has one, and only one, substantive question. If you have a substantially new follow-up question, you should post a new, separate query. Finally, I continue to be utterly unfamiliar with Overleaf. If you choose to post a new query, you should make clear that any answers must be Overleaf-specific.
    – Mico
    Dec 2 '18 at 16:45












  • Yes, and I appreciate the answer and it works. Thank you. I will be more specific in the future.
    – L. Nielsen
    Dec 2 '18 at 16:51














7












7








7






Here's an environment-based solution.



enter image description here



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage[demo]{graphicx} % remove 'demo' option in real document
usepackage{subcaption,float}

newenvironment{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}}{%
end{figure}}

begin{document}
setcounter{chapter}{2} % just for this example
begin{sidebyside}%
{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}
end{sidebyside}
end{document}




That said, I agree with @TeXnician that a macro-based solution seems far more natural and at least as straightforward to implement. First the command definition:



newcommand{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}}


Second, a way to call the command:



sidebyside{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}





share|improve this answer












Here's an environment-based solution.



enter image description here



documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}
usepackage[demo]{graphicx} % remove 'demo' option in real document
usepackage{subcaption,float}

newenvironment{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}}{%
end{figure}}

begin{document}
setcounter{chapter}{2} % just for this example
begin{sidebyside}%
{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}
end{sidebyside}
end{document}




That said, I agree with @TeXnician that a macro-based solution seems far more natural and at least as straightforward to implement. First the command definition:



newcommand{sidebyside}[6]{%
begin{figure}[H]
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#1}
caption{#2}
end{subfigure}hspace{fill}%
begin{subfigure}[b]{0.49textwidth}
includegraphics[width=textwidth]{Lists/Images/#3}
caption{#4}
end{subfigure}
caption{protectraggedright #5}
label{#6}
end{figure}}


Second, a way to call the command:



sidebyside{pic1}{Caption of first subfigure}%
{pic2}{Caption of second subfigure}%
{Overall caption}{fig:x}






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 2 '18 at 14:30









Mico

273k30369756




273k30369756












  • This works fine for me, because I know how to use it, but my colleagues doesn't know what to write in the different { }, no matter how many times I tell them. Do you any way to make it like I've described in my post-edit?
    – L. Nielsen
    Dec 2 '18 at 15:03








  • 2




    @L.Nielsen - Your follow-up question would appear to be highly editor-dependent. I'm afraid I am utterly unfamiliar with Overleaf. Maybe post a query on the Overleaf help site for advice on generating a pop-up window?
    – Mico
    Dec 2 '18 at 15:10












  • Ah, I see my question is hard to understand still... I'm not talking about pop-up windows :/..... You know how the begin{figure} environment folds out? I have made a video, showing what I want to happen: youtu.be/vEBT6Z5TwJQ . Please read the description in the video, as I can't make annotations anymore...
    – L. Nielsen
    Dec 2 '18 at 16:32










  • @L.Nielsen - Your original query was, "I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command". That's the query I tried to answer. This site really only works well if each query has one, and only one, substantive question. If you have a substantially new follow-up question, you should post a new, separate query. Finally, I continue to be utterly unfamiliar with Overleaf. If you choose to post a new query, you should make clear that any answers must be Overleaf-specific.
    – Mico
    Dec 2 '18 at 16:45












  • Yes, and I appreciate the answer and it works. Thank you. I will be more specific in the future.
    – L. Nielsen
    Dec 2 '18 at 16:51


















  • This works fine for me, because I know how to use it, but my colleagues doesn't know what to write in the different { }, no matter how many times I tell them. Do you any way to make it like I've described in my post-edit?
    – L. Nielsen
    Dec 2 '18 at 15:03








  • 2




    @L.Nielsen - Your follow-up question would appear to be highly editor-dependent. I'm afraid I am utterly unfamiliar with Overleaf. Maybe post a query on the Overleaf help site for advice on generating a pop-up window?
    – Mico
    Dec 2 '18 at 15:10












  • Ah, I see my question is hard to understand still... I'm not talking about pop-up windows :/..... You know how the begin{figure} environment folds out? I have made a video, showing what I want to happen: youtu.be/vEBT6Z5TwJQ . Please read the description in the video, as I can't make annotations anymore...
    – L. Nielsen
    Dec 2 '18 at 16:32










  • @L.Nielsen - Your original query was, "I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command". That's the query I tried to answer. This site really only works well if each query has one, and only one, substantive question. If you have a substantially new follow-up question, you should post a new, separate query. Finally, I continue to be utterly unfamiliar with Overleaf. If you choose to post a new query, you should make clear that any answers must be Overleaf-specific.
    – Mico
    Dec 2 '18 at 16:45












  • Yes, and I appreciate the answer and it works. Thank you. I will be more specific in the future.
    – L. Nielsen
    Dec 2 '18 at 16:51
















This works fine for me, because I know how to use it, but my colleagues doesn't know what to write in the different { }, no matter how many times I tell them. Do you any way to make it like I've described in my post-edit?
– L. Nielsen
Dec 2 '18 at 15:03






This works fine for me, because I know how to use it, but my colleagues doesn't know what to write in the different { }, no matter how many times I tell them. Do you any way to make it like I've described in my post-edit?
– L. Nielsen
Dec 2 '18 at 15:03






2




2




@L.Nielsen - Your follow-up question would appear to be highly editor-dependent. I'm afraid I am utterly unfamiliar with Overleaf. Maybe post a query on the Overleaf help site for advice on generating a pop-up window?
– Mico
Dec 2 '18 at 15:10






@L.Nielsen - Your follow-up question would appear to be highly editor-dependent. I'm afraid I am utterly unfamiliar with Overleaf. Maybe post a query on the Overleaf help site for advice on generating a pop-up window?
– Mico
Dec 2 '18 at 15:10














Ah, I see my question is hard to understand still... I'm not talking about pop-up windows :/..... You know how the begin{figure} environment folds out? I have made a video, showing what I want to happen: youtu.be/vEBT6Z5TwJQ . Please read the description in the video, as I can't make annotations anymore...
– L. Nielsen
Dec 2 '18 at 16:32




Ah, I see my question is hard to understand still... I'm not talking about pop-up windows :/..... You know how the begin{figure} environment folds out? I have made a video, showing what I want to happen: youtu.be/vEBT6Z5TwJQ . Please read the description in the video, as I can't make annotations anymore...
– L. Nielsen
Dec 2 '18 at 16:32












@L.Nielsen - Your original query was, "I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command". That's the query I tried to answer. This site really only works well if each query has one, and only one, substantive question. If you have a substantially new follow-up question, you should post a new, separate query. Finally, I continue to be utterly unfamiliar with Overleaf. If you choose to post a new query, you should make clear that any answers must be Overleaf-specific.
– Mico
Dec 2 '18 at 16:45






@L.Nielsen - Your original query was, "I'm looking for a way to make 2 images stand side by side by defining a new ENVIRONMENT, not a command". That's the query I tried to answer. This site really only works well if each query has one, and only one, substantive question. If you have a substantially new follow-up question, you should post a new, separate query. Finally, I continue to be utterly unfamiliar with Overleaf. If you choose to post a new query, you should make clear that any answers must be Overleaf-specific.
– Mico
Dec 2 '18 at 16:45














Yes, and I appreciate the answer and it works. Thank you. I will be more specific in the future.
– L. Nielsen
Dec 2 '18 at 16:51




Yes, and I appreciate the answer and it works. Thank you. I will be more specific in the future.
– L. Nielsen
Dec 2 '18 at 16:51


















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.





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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462814%2fdefining-a-new-environment%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

AnyDesk - Fatal Program Failure

How to calibrate 16:9 built-in touch-screen to a 4:3 resolution?

QoS: MAC-Priority for clients behind a repeater