#Batting of argument name and function name

11 messages · Page 1 of 1 (latest)

deep shore
#

Hello. I tried to define following function:

#let title(title:"Paper Title", size: 17pt,align: center) = {
  align(align,text(size)[#title])
  }

for a result like

#align(center, text(17pt)[
  Paper title
])

But this does not work because the name of argument 'align' and a function name ' align' are same. To avoid this batting, I wrote a code:

#let al = align
#let title(title: "Paper Title", size: 17pt, align: center) = {
  al(align, text(size)[#title])
}

This solved the problem, but this is not good for others to read. How can I deal with this problem?

urban coral
#

your solution potentially causes more issues for everything else in the document

#

I'd just change the argument name instead of making an alias for the built-in function

deep shore
#

I also thought about changing argument name, but I rejected because it causes confuse.

urban coral
#

change it to align-to or alignment

#

how to deal with shadowing built-in functions while still making them usable is still an open question so for now you have to work around it by just not shadowing

deep shore
#

OK. I'll do so. Thank you for providing information and helping me!

silent burrow
#

if you ever need to define a variable named al, you can just shadow that one too

#

so that solution is mostly fine

#

though i agree it may be confusing to read