In the typsetting language Latex the macro \LaTeX
outputs the Latex logo:
How can I achive a similar result in Typst?
Background: This should serve as example for how to manipulate character placement.
As a complement on @cknoll's answer, you can actually just replace all occurences of "LaTeX" with the appropriate symbol by using #show "LaTeX": LaTeX
.
Full code:
#let LaTeX = {
[L];box(move(
dx: -4.2pt, dy: -1.2pt,
box(scale(65%)[A])
));box(move(
dx: -5.7pt, dy: 0pt,
[T]
));box(move(
dx: -7.0pt, dy: 2.7pt,
box(scale(100%)[E])
));box(move(
dx: -8.0pt, dy: 0pt,
[X]
));h(-8.0pt)
}
#show "LaTeX": LaTeX
Now all occurrences of "LaTeX" will be automatically replaced with the corresponding symbol.
The output in the other answers is rather distinct from the LaTeX logo. I believe this is because the numbers aren't quite right and/or they didn't use the right font. A different solution can be found on the GitHub issues page (issue 1987) which I paraphrase for convenience:
#let latex = {
set text(font: "New Computer Modern")
box(width: 2.55em, {
[L]
place(top, dx: 0.3em, text(size: 0.7em)[A])
place(top, dx: 0.7em)[T]
place(top, dx: 1.26em, dy: 0.22em)[E]
place(top, dx: 1.8em)[X]
})
}
#show "LaTeX": latex
Typst is a great alternative to LaTeX
Note the L pokes into the space for A, and the E touches the T and X.
There is also a related issue 1732 with other different solutions.
This is a selfcontained Typst document which defines a
LATEX
-function and uses it: