1

I have the following code

def latex_template(name, title):
return '\n'.join((r"\begin{figure}[ht]",
                  r"    This is a custom LaTeX template!",
                  r"    \centering",
                  rf"    \incfig[1]{{{name}}}",
                  rf"    \caption{{{title}}}",
                  rf"    \label{{fig:{name}}}",
                  r"\end{figure}"))

and I would like to figure out what is the difference between r and rf. Per google, I get that r means that python should just write out the text as it is. For rf, I get that it has something to do with functions. Is it that with rf we tell python to write what I have but also substituing variables, without executing nothing.

Is this right?

Maths Wizzard
  • 221
  • 1
  • 6
  • 2
    There's also https://stackoverflow.com/q/2081640/1079354 and https://stackoverflow.com/q/5082452/1079354 and https://stackoverflow.com/q/60680478/1079354 and – Makoto Jul 21 '22 at 17:22

1 Answers1

1

It's just a combination of an f-string and r-string.

Bob th
  • 276
  • 1
  • 6