8000 図や表のリファレンスのときに`表1`のように表示されてほしい · Issue #3 · okumuralab/typst-js · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

図や表のリファレンスのときに表1のように表示されてほしい #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tokiedokie opened this issue Apr 2, 2025 · 3 comments

Comments

@tokiedokie
Copy link

英語の場合 "Figure 1"、"Table 1"のように表示されるので、これに合わせて"図1"、"表1"のように表示できると嬉しいです。
https://typst.app/docs/reference/model/figure/

バージョン0.1.3では下記のtypstファイルをコンパイルすると添付のPDFのようになります。

@sometable

#figure(
  caption: "some caption",
  table(
  columns: 2,
  [*Amount*], [*Ingredient*],
  [360g], [Baking flour],
  [250g], [Butter (room temp.)],
  [150g], [Brown sugar],
  [100g], [Cane sugar],
  [100g], [70% cocoa chocolate],
  [100g], [35-40% cocoa chocolate],
  [2], [Eggs],
  [Pinch], [Salt],
  [Drizzle], [Vanilla extract],
)
) <sometable>

#import "@preview/js:0.1.3": *
#show: js.with(
  lang: "ja",
)

@sometable

sample.pdf

@okumuralab
Copy link
Owner

申し訳ありません。実はその機能はデフォルトではあるのですが、「図 1」ならまだしも、勝手に「節 1」「式 1」などのように日本語が付いて参照されるのがわずらわしいので、set ref(supplement: none) で殺してしまっていました。やっぱり付いたほうがいいでしょうか。ちょっと考えます。とりあえず set ref(supplement: none) という1行を消せば「図」や「節」が付くようになりますので、お試しください。あるいは、文書ファイルに

#set ref(supplement: auto)

と書いていただいても同じです。

@kimushun1101
Copy link

@okumuralab
私が作成したテンプレートでは以下のように実装しております。

  • 図、表、定義、定理などはデフォルト。supplementによる表示通り。
  • 数式は括弧付きで記載。(1), (2)など。
  • 章、節、項はその場所に応じて記載。章へのラベルであれば1章、節へのラベルであれば1章1節、項へのラベルであれば1章1節1項など。
  • (独自実装)付録は内部的にはheading(章などと同じ扱い)なのですが、付録Aなど記載。

ソースコードは以下です。

https://github.com/kimushun1101/typst-jp-conf-template/blob/43d7b2b74877c0d91330322b6f5d5c43576f6fb2/jaconf-mscs/lib.typ#L56-L87

もしよろしければプルリクエストを出させていただきますので、typst-jsテンプレートで実装したいsupplement表示に関する仕様を教えていただけますでしょうか?
たとえば、現在のset ref(supplement: none)の設定のように、このsupplementについては数字だけの表示にしたいなどの実装も可能です。

@okumuralab
Copy link
Owner

ありがとうございます。実はまだそのあたりの仕様については迷っているところです。お教えいただいたソース、たいへん参考になります。そのうち整理して反映したいと存じます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0