What is the difference between a macro with no arguments and a name?

  • Context: LaTeX 
  • Thread starter Thread starter Eclair_de_XII
  • Start date Start date
  • Tags Tags
    Difference
Click For Summary
SUMMARY

The discussion clarifies the distinction between a name and a macro in LaTeX, specifically using the examples "\PFlink" as a name and "\linkToPF" as a macro. Both serve the same purpose of linking to Physics Forums but differ in their definitions and usage. The name is defined using the \def command, while the macro is created with \newcommand. Understanding these differences is crucial for proper LaTeX document structuring and avoiding low-level TeX commands in LaTeX documents.

PREREQUISITES
  • Familiarity with LaTeX document structure
  • Understanding of \def and \newcommand commands
  • Basic knowledge of hyperlinking in LaTeX using the hyperref package
  • Concept of function arity in symbolic logic
NEXT STEPS
  • Explore advanced LaTeX macros and their applications
  • Learn about the hyperref package for creating hyperlinks
  • Study the implications of using \def versus \newcommand in LaTeX
  • Investigate the concept of arity in programming languages and symbolic logic
USEFUL FOR

LaTeX users, document authors, and anyone interested in understanding the nuances of macro and name definitions in LaTeX for better document management and structure.

Eclair_de_XII
Messages
1,082
Reaction score
91
TL;DR
Quick question. Title gives the most straight-forward version of it.
This is some sample code that I drew up.

The name is "\PFlink"
The macro is "\linktoPF"

My question is this: Would you be able to tell which is the name and which is the macro without referring to their respective definitions in the pre-amble below?

[CODE highlight="5-6"]\documentclass{article}

\usepackage{hyperref}

\def\PFlink{\href{https://www.physicsforums.com/}{Welcome to Physics Forums!}}
\newcommand{\linkToPF}{\href{https://www.physicsforums.com/}{Welcome to Physics Forums!}}

\begin{document}

\paragraph{Names vs. Macros}
These are links to PhysicsForums.com. One of them is in the form of a name and the other in the form of a macro.
\begin{description}
\item[name] \PFlink
\item[macro] \linkToPF
\end{description}

\end{document}[/CODE]

Functionality-wise, they both seem to do exactly the same thing: link to this site. Are they different in any way, or no? If so, how would you show someone that they are different without telling the arbitrary novice to just look at the definitions of them in the pre-amble?
 
Physics news on Phys.org
The two are functionally equivalent.

This same phenomenon occurs in symbolic logic, where the objects one works with in a language are predicates (eg '='), functions (eg '+'), variables (eg '##x##') and constants (eg '1'), but the concept of constant is redundant because a constant is just a function with no arguments (a 0-ary function, or function with arity zero, in logic jargon). That is, it requires no inputs, and always gives the same output.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
13K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 766 ·
26
Replies
766
Views
745K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
1
Views
3K