Latex Def

⚡ 👉🏻👉🏻👉🏻 INFORMATION AVAILABLE CLICK HERE 👈🏻👈🏻👈🏻
$
\def\myHearts{\color{purple}{\heartsuit}\kern-2.5pt\color{green}{\heartsuit}}
\myHearts\myHearts
$
$
\def\myHearts#1#2{\color{#1}{\heartsuit}\kern-2.5pt\color{#2}{\heartsuit}}
\myHearts{red}{blue}
$
© Copyright 2021. All Rights Reserved.
\def - Used for defining your own commands.
\def command is used to define your own commands (control sequences, macros, definitions); must appear (within math delimiters) before it is used;
The best answers are voted up and rise to the top
Stack Overflow for Teams
– Collaborate and share knowledge with a private group.
Create a free Team
What is Teams?
Asked
11 years, 1 month ago
Active
5 years, 3 months ago
36.7k 19 19 gold badges 101 101 silver badges 155 155 bronze badges
9,314 13 13 gold badges 43 43 silver badges 43 43 bronze badges
6,711 1 1 gold badge 23 23 silver badges 33 33 bronze badges
Does this mean that \let\foo\bar is the same as \def\foo{\expandafter\bar} ? Probably not, but why then?
– Didii
Jul 20 '12 at 9:59
With that definition, writing \foo\alpha at the bottom of the example would expand into \expandafter\bar\alpha ; what that does is first expand \alpha , and then expand \bar (in this case to 'goodbye'). Using \expandafter counts as pretty advanced TeX, and is for the arcane cases where you need to control the order of evaluation in a non-default way. Try TeXing \def\baz{wibble} \def\x#1{-#1-} \x\baz \expandafter\x\baz
– Norman Gray
Jul 20 '12 at 11:15
The closest analogue to \let\foo\bar along the lines @Didii is suggesting would be \expandafter\def\expandafter\foo\expandafter{\bar} . There remain differences even between these, as detailed in Martin Scharrer's answer. But for most purposes, I think they would have much the same effect.
– dubiousjim
Sep 1 '14 at 23:15
Here is some more discussion.
– dubiousjim
Sep 2 '14 at 3:42
@NicholasHamilton It's a similar idea, yes, but that may be a slightly confusing way to think about it, since TeX is rather sui generis in programming language terms. A useful mental model is that TeX macros expand, and the expansion is than expanded, and... so on until the engine arrives at one of the relatively small number of primitives which actually do something, such as adding a box (possibly containing a letter or a paragraph) to a list of boxes. Lower-level TeX programming, and its headaches, is all about controlling what gets expanded when, and to what.
– Norman Gray
May 3 '15 at 15:26
241k 56 56 gold badges 727 727 silver badges 902 902 bronze badges
According to the TeXbook p. 269, the \bgroup control sequence doesn't “represent” an implicit character; it is an implicit character (by definition of implicit characters).
– frougon
Jul 18 '19 at 13:37
@frougon: Not sure what your exact point is here. I don't see a real difference between represents and is in this context. I could also have written "makes it an implicit character" or similar. Keep in mind that not all users here are native English speakers.
– Martin Scharrer ♦
Jul 18 '19 at 13:45
No offense intended, I myself am not a native English speaker. “Represents” implies “is not really”, IMHO. But here, \bgroup is really what DEK calls an implicit character, there is no indirection to follow in order to get from \bgroup to an implicit character.
– frougon
Jul 18 '19 at 13:49
14k 1 1 gold badge 20 20 silver badges 25 25 bronze badges
Your \def statements are missing braces, and remember that unless 'bar' is a primitive then TeX expands the material rather then executing it. Good answer, though: more or less what I've have put.
– Joseph Wright ♦
Jul 27 '10 at 6:10
@Joseph Ah yes, fixed; I never actually use \def , so I'm not surprised I botched the syntax :)
– Michael Mrozek
Jul 27 '10 at 14:34
'pretty completely'... lol, why don't you say 'pretty almost sometimes definately always partially never certainly similar but different'
– Nicholas Hamilton
Jun 29 '16 at 1:29
TeX - LaTeX
Tour
Help
Chat
Contact
Feedback
Mobile
Disable Responsiveness
Company
Stack Overflow
For Teams
Advertise With Us
Hire a Developer
Developer Jobs
About
Press
Legal
Privacy Policy
Terms of Service
Cookie Settings
Cookie Policy
Stack Exchange Network
Technology
Life / Arts
Culture / Recreation
Science
Other
Accept all cookies
Customize settings
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
What is the difference between the \let and \def commands in TeX/LaTeX?
Ideally please provide a simple example that will illustrate the difference between them.
The difference is in the time at which the ‘right hand side’ is evaluated.
Thus \let\foo\bar defines \foo to have the value that \bar had at the point of definition . On the other hand, \def\foo{\bar} in effect defines \foo to have the value that \bar has at the point of use .
However it's also a subtle one, so it might be worth highlighting a few key points:
When TeX encounters control sequences such as \fooi , it evaluates them; if these are macros (that is, they have been defined by \def , or \let equal to something which was defined by \def ), then the result is that they will expand to other tokens, which TeX will then examine in turn, and so on, recursively, until what's left is either ‘primitive’ control sequences or letters (I'm simplifying a little bit).
\fooi expands directly to the characters hello (because \bar initially did, and \fooi was defined to have the same value ).
\fooii , in contrast, expands to \bar , which is then immediately reexamined and reexpanded . In the first case, \bar expands to hello and in the second case to goodbye . The definition of \fooii hasn't changed, but \bar has been redefined in between.
Getting a clear idea of the process of this recursive expansion is very helpful when learning how to develop and debug TeX macros.
While the existing answers are all true I like to highlight one point which wasn't explicitly mentioned yet.
I myself got this information recently from Joseph Wright (see his answer and our comments in Simple un-obfuscation of some LaTeX internals ).
As Michael said \let\macroa\macrob "copies" the definition of \macrob to \macroa . However an IMHO important thing here is that the definition isn't actually copied, i.e. exists twice, but the command sequence \macroa now points to the same hash table entry as \macrob .
This means that \let\macroa\macrob uses less memory space (very important in the early days but not anymore) and is faster then \def\macroa{\macrob} because in the second form two command sequence names have to be resolved in the hash table.
Also \let actually "copies" the definition of tokens , which do not need to be macros/command sequences. This allows the definition of command sequences representing implicit characters like \let\bgroup={ .
They're pretty completely different. \let copies a command to a new name, while \def creates a new command.
creates a new command \foo , that evaluates to bar when run.
copies the commands from the \bar commands to the \foo command, so you can call either. Because it's a copy (and not a pointer from one to the other), redefining \foo won't change the behavior of \baz . Hence:
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa . rev 2021.8.27.40079
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .
https://www.tutorialspoint.com/tex_commands/def.htm
https://tex.stackexchange.com/questions/258/what-is-the-difference-between-let-and-def
Body Massage Shymkent
Sex Big Gif Mastrubat Old Nanny
Better Shaped Female Creatures
\def - Tex Command
macros - What is the difference between \let and \def ...
LaTeX Color Definitions
List of LaTeX symbols | LaTeX Wiki | Fandom
LATEX Mathematical Symbols - Rice University
Defining your own commands - Overleaf, Online LaTeX Editor
Help:Displaying a formula - Wikipedia
Latex Def







































































