Error: Argument of newcommand{…} has an extra }












1














I am trying to create a new command to help formatting the entries of the list of figures. Argument 1 should be optional and contain the date the source was accessed, argument 2 is simply the figure's caption I want to show up in the list of figures, and argument 3 is a hyperlink to the source of the image. I want the source and date to only show up in the list of figures and not underneath the actual image. I wrote this in the preamble:



newcommand{lof}[3]{
textbf{#2}
linebreak
{scriptsize #3 #1}
}


This is the caption of some figure:



caption[
lof[(Accessed on 02.01.2019)]
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
]
{Basic neural network with three layers}


Note that I want to be able to declare that the image is my own, in which case the hyperlink and the date should be omitted.



caption[
{Basic neural network with three layers}
{Made by the author.}
]
{Basic neural network with three layers}


This gives me the following error:



! Argument of \lof has an extra }.


However, the brackets should be balanced if I am not completely mistaken. I have read somewhere that there are 'fragile' commands, and using them leads to the same error message I got. Might url{} be a fragile command? Or have I messed up the command definition somehow?



Edit:



The following code shows everything that might be related to the problem. If I remove these parts from the code, the LaTeX documents compiles.



documentclass{article}
usepackage{wrapfig,graphicx,amsmath,hyperref}

newcommand{lof}[3]{textbf{#2}newline {scriptsize #3 #1}}
begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
caption[ {lof[(Accessed on 02.01.2019)]
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ]
{Basic neural network with three layers}
label{fig:nn}
end{wrapfigure}

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
caption[{lof{$boldsymbol{sigma (x)}$, the sigmoid function}
{Created by the author}}]
{$sigma (x)$, the sigmoid function}
label{fig:sigmoid}
end{wrapfigure}

end{document}









share|improve this question




















  • 1




    caption[ {lof[(Accessed on 02.01.2019)] {Basic neural network with three layers} {url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ] {Basic neural network with three layers} -- you must enclose the lot[...]{}{} command with a {} pair, since it has an optional argument and occurs in the optional argument of caption
    – Christian Hupfer
    Jan 2 at 22:26








  • 1




    You might want to have a look at the xparse package, which makes it considerably easier to define commands with multiple optonal arguments.
    – GuM
    Jan 2 at 22:33






  • 1




    @Terrenay: Then add the complete code, not just fragments only
    – Christian Hupfer
    Jan 2 at 22:36






  • 1




    As you are new, I extended your fragment with the missing definitions and replacing with generally available images, however it does not produce the error that you are asking about. Please edit the example so that it is an example of the error.
    – David Carlisle
    Jan 2 at 22:58






  • 1




    also you should delete your .aux and .lof files which may be corrupted by previous errors.
    – David Carlisle
    Jan 2 at 23:02


















1














I am trying to create a new command to help formatting the entries of the list of figures. Argument 1 should be optional and contain the date the source was accessed, argument 2 is simply the figure's caption I want to show up in the list of figures, and argument 3 is a hyperlink to the source of the image. I want the source and date to only show up in the list of figures and not underneath the actual image. I wrote this in the preamble:



newcommand{lof}[3]{
textbf{#2}
linebreak
{scriptsize #3 #1}
}


This is the caption of some figure:



caption[
lof[(Accessed on 02.01.2019)]
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
]
{Basic neural network with three layers}


Note that I want to be able to declare that the image is my own, in which case the hyperlink and the date should be omitted.



caption[
{Basic neural network with three layers}
{Made by the author.}
]
{Basic neural network with three layers}


This gives me the following error:



! Argument of \lof has an extra }.


However, the brackets should be balanced if I am not completely mistaken. I have read somewhere that there are 'fragile' commands, and using them leads to the same error message I got. Might url{} be a fragile command? Or have I messed up the command definition somehow?



Edit:



The following code shows everything that might be related to the problem. If I remove these parts from the code, the LaTeX documents compiles.



documentclass{article}
usepackage{wrapfig,graphicx,amsmath,hyperref}

newcommand{lof}[3]{textbf{#2}newline {scriptsize #3 #1}}
begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
caption[ {lof[(Accessed on 02.01.2019)]
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ]
{Basic neural network with three layers}
label{fig:nn}
end{wrapfigure}

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
caption[{lof{$boldsymbol{sigma (x)}$, the sigmoid function}
{Created by the author}}]
{$sigma (x)$, the sigmoid function}
label{fig:sigmoid}
end{wrapfigure}

end{document}









share|improve this question




















  • 1




    caption[ {lof[(Accessed on 02.01.2019)] {Basic neural network with three layers} {url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ] {Basic neural network with three layers} -- you must enclose the lot[...]{}{} command with a {} pair, since it has an optional argument and occurs in the optional argument of caption
    – Christian Hupfer
    Jan 2 at 22:26








  • 1




    You might want to have a look at the xparse package, which makes it considerably easier to define commands with multiple optonal arguments.
    – GuM
    Jan 2 at 22:33






  • 1




    @Terrenay: Then add the complete code, not just fragments only
    – Christian Hupfer
    Jan 2 at 22:36






  • 1




    As you are new, I extended your fragment with the missing definitions and replacing with generally available images, however it does not produce the error that you are asking about. Please edit the example so that it is an example of the error.
    – David Carlisle
    Jan 2 at 22:58






  • 1




    also you should delete your .aux and .lof files which may be corrupted by previous errors.
    – David Carlisle
    Jan 2 at 23:02
















1












1








1







I am trying to create a new command to help formatting the entries of the list of figures. Argument 1 should be optional and contain the date the source was accessed, argument 2 is simply the figure's caption I want to show up in the list of figures, and argument 3 is a hyperlink to the source of the image. I want the source and date to only show up in the list of figures and not underneath the actual image. I wrote this in the preamble:



newcommand{lof}[3]{
textbf{#2}
linebreak
{scriptsize #3 #1}
}


This is the caption of some figure:



caption[
lof[(Accessed on 02.01.2019)]
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
]
{Basic neural network with three layers}


Note that I want to be able to declare that the image is my own, in which case the hyperlink and the date should be omitted.



caption[
{Basic neural network with three layers}
{Made by the author.}
]
{Basic neural network with three layers}


This gives me the following error:



! Argument of \lof has an extra }.


However, the brackets should be balanced if I am not completely mistaken. I have read somewhere that there are 'fragile' commands, and using them leads to the same error message I got. Might url{} be a fragile command? Or have I messed up the command definition somehow?



Edit:



The following code shows everything that might be related to the problem. If I remove these parts from the code, the LaTeX documents compiles.



documentclass{article}
usepackage{wrapfig,graphicx,amsmath,hyperref}

newcommand{lof}[3]{textbf{#2}newline {scriptsize #3 #1}}
begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
caption[ {lof[(Accessed on 02.01.2019)]
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ]
{Basic neural network with three layers}
label{fig:nn}
end{wrapfigure}

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
caption[{lof{$boldsymbol{sigma (x)}$, the sigmoid function}
{Created by the author}}]
{$sigma (x)$, the sigmoid function}
label{fig:sigmoid}
end{wrapfigure}

end{document}









share|improve this question















I am trying to create a new command to help formatting the entries of the list of figures. Argument 1 should be optional and contain the date the source was accessed, argument 2 is simply the figure's caption I want to show up in the list of figures, and argument 3 is a hyperlink to the source of the image. I want the source and date to only show up in the list of figures and not underneath the actual image. I wrote this in the preamble:



newcommand{lof}[3]{
textbf{#2}
linebreak
{scriptsize #3 #1}
}


This is the caption of some figure:



caption[
lof[(Accessed on 02.01.2019)]
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
]
{Basic neural network with three layers}


Note that I want to be able to declare that the image is my own, in which case the hyperlink and the date should be omitted.



caption[
{Basic neural network with three layers}
{Made by the author.}
]
{Basic neural network with three layers}


This gives me the following error:



! Argument of \lof has an extra }.


However, the brackets should be balanced if I am not completely mistaken. I have read somewhere that there are 'fragile' commands, and using them leads to the same error message I got. Might url{} be a fragile command? Or have I messed up the command definition somehow?



Edit:



The following code shows everything that might be related to the problem. If I remove these parts from the code, the LaTeX documents compiles.



documentclass{article}
usepackage{wrapfig,graphicx,amsmath,hyperref}

newcommand{lof}[3]{textbf{#2}newline {scriptsize #3 #1}}
begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
caption[ {lof[(Accessed on 02.01.2019)]
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ]
{Basic neural network with three layers}
label{fig:nn}
end{wrapfigure}

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
caption[{lof{$boldsymbol{sigma (x)}$, the sigmoid function}
{Created by the author}}]
{$sigma (x)$, the sigmoid function}
label{fig:sigmoid}
end{wrapfigure}

end{document}






macros table-of-contents errors hyperref urls






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 23:00









David Carlisle

484k4011171859




484k4011171859










asked Jan 2 at 22:25









TerrenayTerrenay

83




83








  • 1




    caption[ {lof[(Accessed on 02.01.2019)] {Basic neural network with three layers} {url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ] {Basic neural network with three layers} -- you must enclose the lot[...]{}{} command with a {} pair, since it has an optional argument and occurs in the optional argument of caption
    – Christian Hupfer
    Jan 2 at 22:26








  • 1




    You might want to have a look at the xparse package, which makes it considerably easier to define commands with multiple optonal arguments.
    – GuM
    Jan 2 at 22:33






  • 1




    @Terrenay: Then add the complete code, not just fragments only
    – Christian Hupfer
    Jan 2 at 22:36






  • 1




    As you are new, I extended your fragment with the missing definitions and replacing with generally available images, however it does not produce the error that you are asking about. Please edit the example so that it is an example of the error.
    – David Carlisle
    Jan 2 at 22:58






  • 1




    also you should delete your .aux and .lof files which may be corrupted by previous errors.
    – David Carlisle
    Jan 2 at 23:02
















  • 1




    caption[ {lof[(Accessed on 02.01.2019)] {Basic neural network with three layers} {url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ] {Basic neural network with three layers} -- you must enclose the lot[...]{}{} command with a {} pair, since it has an optional argument and occurs in the optional argument of caption
    – Christian Hupfer
    Jan 2 at 22:26








  • 1




    You might want to have a look at the xparse package, which makes it considerably easier to define commands with multiple optonal arguments.
    – GuM
    Jan 2 at 22:33






  • 1




    @Terrenay: Then add the complete code, not just fragments only
    – Christian Hupfer
    Jan 2 at 22:36






  • 1




    As you are new, I extended your fragment with the missing definitions and replacing with generally available images, however it does not produce the error that you are asking about. Please edit the example so that it is an example of the error.
    – David Carlisle
    Jan 2 at 22:58






  • 1




    also you should delete your .aux and .lof files which may be corrupted by previous errors.
    – David Carlisle
    Jan 2 at 23:02










1




1




caption[ {lof[(Accessed on 02.01.2019)] {Basic neural network with three layers} {url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ] {Basic neural network with three layers} -- you must enclose the lot[...]{}{} command with a {} pair, since it has an optional argument and occurs in the optional argument of caption
– Christian Hupfer
Jan 2 at 22:26






caption[ {lof[(Accessed on 02.01.2019)] {Basic neural network with three layers} {url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}} ] {Basic neural network with three layers} -- you must enclose the lot[...]{}{} command with a {} pair, since it has an optional argument and occurs in the optional argument of caption
– Christian Hupfer
Jan 2 at 22:26






1




1




You might want to have a look at the xparse package, which makes it considerably easier to define commands with multiple optonal arguments.
– GuM
Jan 2 at 22:33




You might want to have a look at the xparse package, which makes it considerably easier to define commands with multiple optonal arguments.
– GuM
Jan 2 at 22:33




1




1




@Terrenay: Then add the complete code, not just fragments only
– Christian Hupfer
Jan 2 at 22:36




@Terrenay: Then add the complete code, not just fragments only
– Christian Hupfer
Jan 2 at 22:36




1




1




As you are new, I extended your fragment with the missing definitions and replacing with generally available images, however it does not produce the error that you are asking about. Please edit the example so that it is an example of the error.
– David Carlisle
Jan 2 at 22:58




As you are new, I extended your fragment with the missing definitions and replacing with generally available images, however it does not produce the error that you are asking about. Please edit the example so that it is an example of the error.
– David Carlisle
Jan 2 at 22:58




1




1




also you should delete your .aux and .lof files which may be corrupted by previous errors.
– David Carlisle
Jan 2 at 23:02






also you should delete your .aux and .lof files which may be corrupted by previous errors.
– David Carlisle
Jan 2 at 23:02












1 Answer
1






active

oldest

votes


















2














I get no error, but your input is very awkward and error prone.



I suggest to define a new xcaption command, so as to minimize the burden.



documentclass{article}
usepackage{xparse}
usepackage{amsmath}
usepackage{wrapfig}
usepackage{graphicx}
usepackage{hyperref}

usepackage{kantlipsum}

NewDocumentCommand{xcaption}{O{#2}mmo}{%
caption[lof{#1}{#3IfValueT{#4}{ #4}}]{#2}%
}
NewDocumentCommand{lof}{mm}{%
{boldmathtextbf{#1}}newline
{scriptsize #2}%
}

begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
xcaption
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
[(Accessed on 02.01.2019)]
label{fig:nn}
end{wrapfigure}

kant[1]

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
xcaption
[Short caption with $sigma(x)$]
{$sigma (x)$, the sigmoid function}
{Created by the author}
label{fig:sigmoid}
end{wrapfigure}

kant[1]

end{document}


The syntax is



xcaption
[<optional caption for the lof>]
{<main caption>}
{<attribution>}
[<optional info>]


I added an example of the optional caption, also showing how to get bold math without explicitly adding boldsymbol.



The lof command is only auxiliary and it shouldn't be really used in the document.



enter image description here






share|improve this answer





















  • Thank you, this is a really smooth way to do it! I did not know about NewDocumentCommand until now. For some reason though, I had to change the order of the arguments to [short caption]{main caption}[additional]{attribution}, supposedly because the optional argument in the last slot was not seen as part of the command anymore. (Accessed on) was printed right underneath the image's main caption and not in the list of figures.
    – Terrenay
    Jan 3 at 11:11











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%2f468333%2ferror-argument-of-newcommand-has-an-extra%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









2














I get no error, but your input is very awkward and error prone.



I suggest to define a new xcaption command, so as to minimize the burden.



documentclass{article}
usepackage{xparse}
usepackage{amsmath}
usepackage{wrapfig}
usepackage{graphicx}
usepackage{hyperref}

usepackage{kantlipsum}

NewDocumentCommand{xcaption}{O{#2}mmo}{%
caption[lof{#1}{#3IfValueT{#4}{ #4}}]{#2}%
}
NewDocumentCommand{lof}{mm}{%
{boldmathtextbf{#1}}newline
{scriptsize #2}%
}

begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
xcaption
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
[(Accessed on 02.01.2019)]
label{fig:nn}
end{wrapfigure}

kant[1]

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
xcaption
[Short caption with $sigma(x)$]
{$sigma (x)$, the sigmoid function}
{Created by the author}
label{fig:sigmoid}
end{wrapfigure}

kant[1]

end{document}


The syntax is



xcaption
[<optional caption for the lof>]
{<main caption>}
{<attribution>}
[<optional info>]


I added an example of the optional caption, also showing how to get bold math without explicitly adding boldsymbol.



The lof command is only auxiliary and it shouldn't be really used in the document.



enter image description here






share|improve this answer





















  • Thank you, this is a really smooth way to do it! I did not know about NewDocumentCommand until now. For some reason though, I had to change the order of the arguments to [short caption]{main caption}[additional]{attribution}, supposedly because the optional argument in the last slot was not seen as part of the command anymore. (Accessed on) was printed right underneath the image's main caption and not in the list of figures.
    – Terrenay
    Jan 3 at 11:11
















2














I get no error, but your input is very awkward and error prone.



I suggest to define a new xcaption command, so as to minimize the burden.



documentclass{article}
usepackage{xparse}
usepackage{amsmath}
usepackage{wrapfig}
usepackage{graphicx}
usepackage{hyperref}

usepackage{kantlipsum}

NewDocumentCommand{xcaption}{O{#2}mmo}{%
caption[lof{#1}{#3IfValueT{#4}{ #4}}]{#2}%
}
NewDocumentCommand{lof}{mm}{%
{boldmathtextbf{#1}}newline
{scriptsize #2}%
}

begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
xcaption
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
[(Accessed on 02.01.2019)]
label{fig:nn}
end{wrapfigure}

kant[1]

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
xcaption
[Short caption with $sigma(x)$]
{$sigma (x)$, the sigmoid function}
{Created by the author}
label{fig:sigmoid}
end{wrapfigure}

kant[1]

end{document}


The syntax is



xcaption
[<optional caption for the lof>]
{<main caption>}
{<attribution>}
[<optional info>]


I added an example of the optional caption, also showing how to get bold math without explicitly adding boldsymbol.



The lof command is only auxiliary and it shouldn't be really used in the document.



enter image description here






share|improve this answer





















  • Thank you, this is a really smooth way to do it! I did not know about NewDocumentCommand until now. For some reason though, I had to change the order of the arguments to [short caption]{main caption}[additional]{attribution}, supposedly because the optional argument in the last slot was not seen as part of the command anymore. (Accessed on) was printed right underneath the image's main caption and not in the list of figures.
    – Terrenay
    Jan 3 at 11:11














2












2








2






I get no error, but your input is very awkward and error prone.



I suggest to define a new xcaption command, so as to minimize the burden.



documentclass{article}
usepackage{xparse}
usepackage{amsmath}
usepackage{wrapfig}
usepackage{graphicx}
usepackage{hyperref}

usepackage{kantlipsum}

NewDocumentCommand{xcaption}{O{#2}mmo}{%
caption[lof{#1}{#3IfValueT{#4}{ #4}}]{#2}%
}
NewDocumentCommand{lof}{mm}{%
{boldmathtextbf{#1}}newline
{scriptsize #2}%
}

begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
xcaption
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
[(Accessed on 02.01.2019)]
label{fig:nn}
end{wrapfigure}

kant[1]

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
xcaption
[Short caption with $sigma(x)$]
{$sigma (x)$, the sigmoid function}
{Created by the author}
label{fig:sigmoid}
end{wrapfigure}

kant[1]

end{document}


The syntax is



xcaption
[<optional caption for the lof>]
{<main caption>}
{<attribution>}
[<optional info>]


I added an example of the optional caption, also showing how to get bold math without explicitly adding boldsymbol.



The lof command is only auxiliary and it shouldn't be really used in the document.



enter image description here






share|improve this answer












I get no error, but your input is very awkward and error prone.



I suggest to define a new xcaption command, so as to minimize the burden.



documentclass{article}
usepackage{xparse}
usepackage{amsmath}
usepackage{wrapfig}
usepackage{graphicx}
usepackage{hyperref}

usepackage{kantlipsum}

NewDocumentCommand{xcaption}{O{#2}mmo}{%
caption[lof{#1}{#3IfValueT{#4}{ #4}}]{#2}%
}
NewDocumentCommand{lof}{mm}{%
{boldmathtextbf{#1}}newline
{scriptsize #2}%
}

begin{document}

listoffigures

begin{wrapfigure}{r}{0.25textwidth}
centering
includegraphics[width=0.25textwidth]{example-image}
xcaption
{Basic neural network with three layers}
{url{https://commons.wikimedia.org/wiki/File:Artificial_neural_network.svg}}
[(Accessed on 02.01.2019)]
label{fig:nn}
end{wrapfigure}

kant[1]

begin{wrapfigure}{h}{0.5textwidth}
centering
includegraphics[width=0.5textwidth]{example-image}
xcaption
[Short caption with $sigma(x)$]
{$sigma (x)$, the sigmoid function}
{Created by the author}
label{fig:sigmoid}
end{wrapfigure}

kant[1]

end{document}


The syntax is



xcaption
[<optional caption for the lof>]
{<main caption>}
{<attribution>}
[<optional info>]


I added an example of the optional caption, also showing how to get bold math without explicitly adding boldsymbol.



The lof command is only auxiliary and it shouldn't be really used in the document.



enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 2 at 23:14









egregegreg

711k8618913174




711k8618913174












  • Thank you, this is a really smooth way to do it! I did not know about NewDocumentCommand until now. For some reason though, I had to change the order of the arguments to [short caption]{main caption}[additional]{attribution}, supposedly because the optional argument in the last slot was not seen as part of the command anymore. (Accessed on) was printed right underneath the image's main caption and not in the list of figures.
    – Terrenay
    Jan 3 at 11:11


















  • Thank you, this is a really smooth way to do it! I did not know about NewDocumentCommand until now. For some reason though, I had to change the order of the arguments to [short caption]{main caption}[additional]{attribution}, supposedly because the optional argument in the last slot was not seen as part of the command anymore. (Accessed on) was printed right underneath the image's main caption and not in the list of figures.
    – Terrenay
    Jan 3 at 11:11
















Thank you, this is a really smooth way to do it! I did not know about NewDocumentCommand until now. For some reason though, I had to change the order of the arguments to [short caption]{main caption}[additional]{attribution}, supposedly because the optional argument in the last slot was not seen as part of the command anymore. (Accessed on) was printed right underneath the image's main caption and not in the list of figures.
– Terrenay
Jan 3 at 11:11




Thank you, this is a really smooth way to do it! I did not know about NewDocumentCommand until now. For some reason though, I had to change the order of the arguments to [short caption]{main caption}[additional]{attribution}, supposedly because the optional argument in the last slot was not seen as part of the command anymore. (Accessed on) was printed right underneath the image's main caption and not in the list of figures.
– Terrenay
Jan 3 at 11:11


















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%2f468333%2ferror-argument-of-newcommand-has-an-extra%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

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents