Skip to main content
added 143 characters in body
Source Link
cabohah
  • 17.9k
  • 1
  • 10
  • 26

I do not really understand, what you are trying, but the first argument of \ifthenelse should surely be a comparison, maybe something like:

\documentclass{article}
\usepackage{ifthen}
\usepackage{currfile}

\newcommand{\textforpicture}[1]{%
  \ifthenelse{\equal{#1}{John}}
    {This is text 1 and the name of this file is \currfilebase}%
    {\ifthenelse{\equal{#1}{Jack}}
      {This is text 2 and the name of this file is \currfilebase}%
      {\ifthenelse{\equal{#1}{Jill}}
        {This is text 3 and the name of this file is \currfilebase}
        {nothing}
      }%
    }%
}%
  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

enter image description here

For such cases, you can also use l3:

\documentclass{article}

\ExplSyntaxOn
\newcommand%\newcommand{\textforpicture}[1][1]% could be used, but using
\NewDocumentCommand \textforpicture { m } % is usual for defining a user command in l3 context.
  {
    \str_case:nnF { #1 }
      {
        {John} {This~is~text~1}
        {Jack} {This~is~text~2}
        {Jill} {This~is~text~3}
      }
      {nothing}
  }%
\ExplSyntaxOff  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

I've removed currfile in this second example, because I've not understood, why you are using it. And IMHO it is also not needed to show, how to use \str_case:nnF.

Please have a look into “The LaTeX3 interfaces” for more information about using LaTeX3.

I do not really understand, what you are trying, but the first argument of \ifthenelse should surely be a comparison, maybe something like:

\documentclass{article}
\usepackage{ifthen}
\usepackage{currfile}

\newcommand{\textforpicture}[1]{%
  \ifthenelse{\equal{#1}{John}}
    {This is text 1 and the name of this file is \currfilebase}%
    {\ifthenelse{\equal{#1}{Jack}}
      {This is text 2 and the name of this file is \currfilebase}%
      {\ifthenelse{\equal{#1}{Jill}}
        {This is text 3 and the name of this file is \currfilebase}
        {nothing}
      }%
    }%
}%
  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

enter image description here

For such cases, you can also use l3:

\documentclass{article}

\ExplSyntaxOn
\newcommand{\textforpicture}[1]{%
  \str_case:nnF { #1 }
    {
      {John} {This~is~text~1}
      {Jack} {This~is~text~2}
      {Jill} {This~is~text~3}
    }
    {nothing}
}%
\ExplSyntaxOff  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

I've removed currfile in this second example, because I've not understood, why you are using it. And IMHO it is also not needed to show, how to use \str_case:nnF.

Please have a look into “The LaTeX3 interfaces” for more information about using LaTeX3.

I do not really understand, what you are trying, but the first argument of \ifthenelse should surely be a comparison, maybe something like:

\documentclass{article}
\usepackage{ifthen}
\usepackage{currfile}

\newcommand{\textforpicture}[1]{%
  \ifthenelse{\equal{#1}{John}}
    {This is text 1 and the name of this file is \currfilebase}%
    {\ifthenelse{\equal{#1}{Jack}}
      {This is text 2 and the name of this file is \currfilebase}%
      {\ifthenelse{\equal{#1}{Jill}}
        {This is text 3 and the name of this file is \currfilebase}
        {nothing}
      }%
    }%
}%
  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

enter image description here

For such cases, you can also use l3:

\documentclass{article}

\ExplSyntaxOn
%\newcommand{\textforpicture}[1]% could be used, but using
\NewDocumentCommand \textforpicture { m } % is usual for defining a user command in l3 context.
  {
    \str_case:nnF { #1 }
      {
        {John} {This~is~text~1}
        {Jack} {This~is~text~2}
        {Jill} {This~is~text~3}
      }
      {nothing}
  }%
\ExplSyntaxOff  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

I've removed currfile in this second example, because I've not understood, why you are using it. And IMHO it is also not needed to show, how to use \str_case:nnF.

Please have a look into “The LaTeX3 interfaces” for more information about using LaTeX3.

added 168 characters in body
Source Link
cabohah
  • 17.9k
  • 1
  • 10
  • 26

I do not really understand, what you are trying, but the first argument of \ifthenelse should surely be a comparison, maybe something like:

\documentclass{article}
\usepackage{ifthen}
\usepackage{currfile}

\newcommand{\textforpicture}[1]{%
  \ifthenelse{\equal{#1}{John}}
    {This is text 1 and the name of this file is \currfilebase}%
    {\ifthenelse{\equal{#1}{Jack}}
      {This is text 2 and the name of this file is \currfilebase}%
      {\ifthenelse{\equal{#1}{Jill}}
        {This is text 3 and the name of this file is \currfilebase}
        {nothing}
      }%
    }%
}%
  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

enter image description here

For such cases, you can also use l3:


\ExplSyntaxOn
\newcommand{\textforpicture}[1]{%
  \str_case:nnF { #1 }
    {
      {John} {This~is~text~1}
      {Jack} {This~is~text~2}
      {Jill} {This~is~text~3}
    }
    {nothing}
}%
\ExplSyntaxOff  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}
\documentclass{article}

\ExplSyntaxOn
\newcommand{\textforpicture}[1]{%
  \str_case:nnF { #1 }
    {
      {John} {This~is~text~1}
      {Jack} {This~is~text~2}
      {Jill} {This~is~text~3}
    }
    {nothing}
}%
\ExplSyntaxOff  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

I've removed currfile in this second example, because I've not understood, why you are using it. And IMHO it is also not needed to show, how to use \str_case:nnF.

Please have a look into “The LaTeX3 interfaces” for more information about using LaTeX3.

I do not really understand, what you are trying, but the first argument of \ifthenelse should surely be a comparison, maybe something like:

\documentclass{article}
\usepackage{ifthen}
\usepackage{currfile}

\newcommand{\textforpicture}[1]{%
  \ifthenelse{\equal{#1}{John}}
    {This is text 1 and the name of this file is \currfilebase}%
    {\ifthenelse{\equal{#1}{Jack}}
      {This is text 2 and the name of this file is \currfilebase}%
      {\ifthenelse{\equal{#1}{Jill}}
        {This is text 3 and the name of this file is \currfilebase}
        {nothing}
      }%
    }%
}%
  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

enter image description here

For such cases, you can also use l3:


\ExplSyntaxOn
\newcommand{\textforpicture}[1]{%
  \str_case:nnF { #1 }
    {
      {John} {This~is~text~1}
      {Jack} {This~is~text~2}
      {Jill} {This~is~text~3}
    }
    {nothing}
}%
\ExplSyntaxOff  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

I do not really understand, what you are trying, but the first argument of \ifthenelse should surely be a comparison, maybe something like:

\documentclass{article}
\usepackage{ifthen}
\usepackage{currfile}

\newcommand{\textforpicture}[1]{%
  \ifthenelse{\equal{#1}{John}}
    {This is text 1 and the name of this file is \currfilebase}%
    {\ifthenelse{\equal{#1}{Jack}}
      {This is text 2 and the name of this file is \currfilebase}%
      {\ifthenelse{\equal{#1}{Jill}}
        {This is text 3 and the name of this file is \currfilebase}
        {nothing}
      }%
    }%
}%
  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

enter image description here

For such cases, you can also use l3:

\documentclass{article}

\ExplSyntaxOn
\newcommand{\textforpicture}[1]{%
  \str_case:nnF { #1 }
    {
      {John} {This~is~text~1}
      {Jack} {This~is~text~2}
      {Jill} {This~is~text~3}
    }
    {nothing}
}%
\ExplSyntaxOff  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

I've removed currfile in this second example, because I've not understood, why you are using it. And IMHO it is also not needed to show, how to use \str_case:nnF.

Please have a look into “The LaTeX3 interfaces” for more information about using LaTeX3.

Source Link
cabohah
  • 17.9k
  • 1
  • 10
  • 26

I do not really understand, what you are trying, but the first argument of \ifthenelse should surely be a comparison, maybe something like:

\documentclass{article}
\usepackage{ifthen}
\usepackage{currfile}

\newcommand{\textforpicture}[1]{%
  \ifthenelse{\equal{#1}{John}}
    {This is text 1 and the name of this file is \currfilebase}%
    {\ifthenelse{\equal{#1}{Jack}}
      {This is text 2 and the name of this file is \currfilebase}%
      {\ifthenelse{\equal{#1}{Jill}}
        {This is text 3 and the name of this file is \currfilebase}
        {nothing}
      }%
    }%
}%
  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}

enter image description here

For such cases, you can also use l3:


\ExplSyntaxOn
\newcommand{\textforpicture}[1]{%
  \str_case:nnF { #1 }
    {
      {John} {This~is~text~1}
      {Jack} {This~is~text~2}
      {Jill} {This~is~text~3}
    }
    {nothing}
}%
\ExplSyntaxOff  

\begin{document}

Experimental text fragement for John: \textforpicture{John}

Experimental text fragement for Jack: \textforpicture{Jack}

Experimental text fragement for Jill: \textforpicture{Jill}

\end{document}