How can I recreate the result of \LaTeX in Typst?

437 views Asked by At

In the typsetting language Latex the macro \LaTeX outputs the Latex logo:

latex logo

How can I achive a similar result in Typst?

Background: This should serve as example for how to manipulate character placement.

3

There are 3 answers

0
cknoll On

This is a selfcontained Typst document which defines a LATEX-function and uses it:

#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)
}


It is possible that #LATEX will soon be obsolete.

Screenshot of a rendered PDF which displays the phrase
"It is possible that LATEX will soon be obsolete." Thereby, the word "LATEX" is typeset in a specific way which is very similar to the original LaTeX-Logo (where the letters A and E are vertically displaced).

0
ecstrema On

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 corresponding output

0
Calvin Khor On

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

enter image description here 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.