Giter Club home page Giter Club logo

Comments (9)

Enivex avatar Enivex commented on June 26, 2024 1

This is yet another result of #366

When typesetting text in math, you should explicitly switch to the text font.

from typst.

cscherrer avatar cscherrer commented on June 26, 2024

Thanks @Enivex , but I don't see how this is at all related to fonts. A double quote on its own is ambiguous, and correct rendering depends on the context to determine which way the quotes should "point". As I understand, #[...] does explicitly switch to text font.

Just to be clear, OP is just a minimal example, the real use case is something like the quotes in this:
image

The only way I could get these quotes correct was to use quote.l.double and quote.r.double, which is extremely clunky.

from typst.

Enivex avatar Enivex commented on June 26, 2024

. As I understand, #[...] does explicitly switch to text font.

No, this is incorrect. As long as you're inside an equation the math font is used. Which isn't really intended for typesetting text, and therefore will cause issues like this.

@cscherrer my suggestion for the time being is to define something like #let mtext = text.with(font: "text font name here”) and then use $ 1 + 1 = 2 quad (#mtext["Profound" equation]) $

This will change, but the design hasn't been decided on yet.

from typst.

cscherrer avatar cscherrer commented on June 26, 2024

Thanks for the suggestion! That gets pretty close, but I'd like to keep the same font. If I do #context text.font it says new computer modern. Then if I do

#let mtext = text.with(font: "new computer modern")

$
1 + 1 &= 2 quad (#mtext["Profound" equation]) \
1 + 1 &= 2 quad (#text["Profound" equation]) 
$

I get

image

The first looks pretty good. I guess the last step is, instead of querying the font and then typing it in, how can I automate this? I tried

#let mtext = text.with(font: text.font)

but that gives an error.

from typst.

Enivex avatar Enivex commented on June 26, 2024

The first looks pretty good. I guess the last step is, instead of querying the font and then typing it in, how can I automate this? I tried

#let mtext = text.with(font: text.font)

but that gives an error.

Unfortunately this is not possible, even adding the context keyword, because the font in the context where function would be used would be the math font. You have to hard code it.

from typst.

cscherrer avatar cscherrer commented on June 26, 2024

That very surprising that you can't just cast an observation from some context into a fixed variable, but I'll take your word for it. Thanks for the help :)

from typst.

laurmaedje avatar laurmaedje commented on June 26, 2024

There might be a misunderstanding. You can store an observation from a context into a fixed variable. But in this case, there is no good place to put the context (at least not automatically) because the font is already configured in the context passed to the equation show rule.

from typst.

cscherrer avatar cscherrer commented on June 26, 2024

Ok, if I put #context text.font in body of my paper, it renders as "new computer modern". How would I instead put that in a fixed variable, say myfont? Then I could follow it with

#let mtext = text.with(font: myfont)

Then I think calling mtext from inside math mode would solve it. I don't need the context placed automatically.

from typst.

laurmaedje avatar laurmaedje commented on June 26, 2024

Ah, no, it doesn't work directly like that, I might have bee the that misunderstood. Everything depending on the context does need to be within the context. But if you have multiple nested contexts, then you can still save the observation from one and access it in the other:

#context {
  let fill = text.fill
  set text(fill: blue)
  context {
    let fill2 = text.fill
    [fill is #fill and fill2 is #fill2]
  }
}

from typst.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.