diff --git a/docs/tutorial/3-advanced.md b/docs/tutorial/3-advanced.md index c29e2cfc5b..b3be096123 100644 --- a/docs/tutorial/3-advanced.md +++ b/docs/tutorial/3-advanced.md @@ -76,7 +76,7 @@ description: Typstチュートリアル ## タイトルとアブストラクトの作成 { #title-and-abstract } それでは、タイトルとアブストラクトを追加しましょう。 -Typst comes with a [`title`]($title) function. Let's start by providing our title as an argument: +Typstには[`title`]($title)関数があります。この関数にタイトルを引数として渡してみましょう。 ```example >>> #set page(width: 300pt, margin: 30pt) @@ -87,40 +87,38 @@ Typst comes with a [`title`]($title) function. Let's start by providing our titl ] ``` -You can see that the title is already boldfaced and has some space around it. -However, it is left-aligned and not exactly 17pt large. Hence, we need to adjust -its appearance. The title function does not come with any arguments for -font or text size we could set. Instead, these properties are defined on the -`text` and `align` functions. +タイトルはすでに太字で、周囲には余白もあります。 +ただし、左揃えで、文字サイズも17ptではありません。 +そこで、見た目を調整しましょう。 +`title`関数には、フォントや文字サイズを設定する引数はありません。 +代わりに、これらのプロパティは`text`関数と`align`関数で設定します。
-What is the difference between what the `title` function inserted and the -headings we produced with equals signs? +`title`関数で挿入したタイトルと、等号で作成した見出しは何が違うのでしょうか? -Headings, even first-level headings, can appear multiple times in your document -whereas a title only appears once, usually at the beginning. Differentiating -between the two helps Typst make your document accessible for users of -Assistive Technology such as screen readers. +第1レベルの見出しを含め、見出しは文書内に複数回出現できます。 +一方、タイトルは通常、文書の冒頭に一度だけ出現します。 +両者を区別しておくと、スクリーンリーダーなどの支援技術を利用する読者にとってアクセシブルな文書を、Typstが生成しやすくなります。
-When we want to customize the properties of some element inside of another kind -of element, we can use show-set rules. First, we use `show` to select which -element we want to customize. We call this a _selector._ Then, we type a colon. -Next, we write the set rule that should apply to elements matching the selector. -Summarized, the syntax looks like this: +ある要素の中にある別の種類の要素のプロパティをカスタマイズするには、show-setルールを使用できます。 +まず、`show`に続けてカスタマイズする要素を指定します。 +この指定を_セレクター_と呼びます。 +次にコロンを入力し、セレクターにマッチする要素に適用するsetルールを記述します。 +まとめると、構文は次のようになります。 ```typ #show your-selector: set some-element(/* ... */) ``` -Let's recall: We want to center-align the title and make it 17pt large. Hence, -we need two show-set rules: +ここで確認しましょう。タイトルを中央揃えにし、文字サイズを17ptにしたいのでした。 +そのため、次の2つのshow-setルールが必要です。 -- One with the selector `title` and the rule `{set text(size: 17pt)}` -- One with the selector `title` and the rule `{set align(center)}` +- セレクターが`title`、ルールが`{set text(size: 17pt)}`のshow-setルール +- セレクターが`title`、ルールが`{set align(center)}`のshow-setルール -Our example now looks like this: +例は次のようになります。 ```example >>> #set page(width: 300pt, margin: 30pt) @@ -134,8 +132,8 @@ Our example now looks like this: ] ``` -This looks right. Let's also add the author list: Since we are writing this -paper together with our supervisor, we'll add our own and their name. +これでよさそうです。著者一覧も追加しましょう。 +この論文は指導教員と共同で執筆しているので、自分の名前と指導教員の名前を追加します。 ```example >>> #set page(width: 300pt, margin: 30pt) @@ -175,13 +173,12 @@ paper together with our supervisor, we'll add our own and their name. grid関数はセルを指定するコンテンツ引数を任意の数で受け取れます。 行は自動的に追加されますが、`rows`引数で手動でサイズを指定することも可能です。 -Looking at the authors and the title, they are a bit too close together. You can -address this by using another show-set rule to configure the space below the -title. The title, the grid, paragraphs, and all other elements that Typst -arranges from the top to the bottom of the page are called _blocks._ Each block -is controlled by the [`block`]($block) function. It controls behaviors like their -distance and whether a block can contain a page break. That means that we can -write another show-set rule that selects the title to set the block spacing: +タイトルと著者一覧を見ると、少し近すぎます。 +この問題は、別のshow-setルールを使ってタイトルの下の間隔を設定することで解決できます。 +タイトルやグリッド、段落など、Typstがページの上から下へ配置する全ての要素を_ブロック_と呼びます。 +各ブロックは[`block`]($block)関数によって制御されます。 +この関数は、ブロック同士の間隔や、ブロック内で改ページできるかどうかなどを制御します。 +つまり、タイトルを選択してブロックの間隔を設定するshow-setルールをさらに記述できます。 ```example >>> #set page(width: 300pt, margin: 30pt) @@ -212,14 +209,13 @@ write another show-set rule that selects the title to set the block spacing: ) ``` -With this show-set rule, we overrode the spacing below the title. We have used -the `em` unit: It allows us to express lengths as multiples of the font size. -Here, we used it to space the title and the author list exactly 1.2× the font -size apart. +このshow-setルールで、タイトルの下の間隔を上書きしました。 +ここでは`em`単位を使用しています。 +`em`を使うと、フォントサイズの倍数で長さを表現できます。 +この例では、タイトルと著者一覧の間隔をフォントサイズのちょうど1.2倍に設定しました。 それでは、アブストラクトを追加しましょう。 -学会は、アブストラクトを中央に配置することを望んでいることを忘れないでください。 -Now, let's add the abstract. Remember that the conference wants the abstract to be set ragged and centered. +学会では、アブストラクトを両端揃えにせず、中央に配置することが求められている点を思い出してください。 ```example:0,0,612,317.5 >>> #set page( @@ -270,98 +266,28 @@ Now, let's add the abstract. Remember that the conference wants the abstract to これは、最初のsetルールの後に指定されたにもかかわらず、文書の残りの部分には影響しません。 コンテンツ・ブロック内で設定されたものは、そのブロック内のコンテンツにのみ影響します。 -Another tweak could be to remove the duplication between the header and the -title element's argument. Since they share the title, it would be convenient to -store it in a place designed to hold metadata about the document. We would then -need a way to retrieve the title in both places. The `document` element can help -us with the former: By using it in a set rule, we can store document metadata -like title, description, and keywords. +さらに、ヘッダーと`title`要素の引数にタイトルを重複して記述している点も改善できます。 +両方で同じタイトルを使うため、文書メタデータを保持するために用意された場所にタイトルを保存できると便利です。 +その場合、両方の場所からタイトルを取得する方法も必要になります。 +タイトルの保存には`document`要素が役立ちます。 +`document`要素をsetルールで使用すると、タイトル、説明、キーワードなどの文書メタデータを保存できます。 ```typ #set document(title: [A Fluid Dynamic Model for Glacier Flow]) ``` -When exporting a PDF, the title set here will appear in the title bar of your -PDF reader. Your operating system will also use this title to make the file -retrievable with search. Last but not least, it contributes to making your -document more accessible and is required if you choose to comply with PDF/UA, a -PDF standard focused on accessibility. +ここで設定したタイトルは、PDFをエクスポートしたときにPDFリーダーのタイトルバーへ表示されます。 +また、オペレーティングシステムの検索でも、このタイトルを使ってファイルを見つけられます。 +さらに、タイトルの設定は文書のアクセシビリティ向上にも役立ち、アクセシビリティを重視したPDF規格であるPDF/UAに準拠する場合には必須です。 -Now, we need a way to retrieve the value we set in the main title and the -header. Because the `title` function is designed to work together with the -`document` element, calling it with no arguments will just print the title. For -the header, we will need to be more explicit: Because Typst has no way of -knowing that we want to insert the title there, we will need to tell it to do so -manually. +次に、設定した値をページ上のタイトルとヘッダーの両方で取得する方法が必要です。 +`title`関数は`document`要素と連携するように設計されているため、引数なしで呼び出すとタイトルが表示されます。 +一方、ヘッダーでは、より明示的に指定する必要があります。 +ヘッダーにタイトルを挿入したいという意図をTypstは判断できないため、手動で指示する必要があります。 -Using _context,_ we can retrieve the contents of any values we have set on -elements before. When we use the `{context}` keyword, we can access any property -of any element, including the document element's title property. Its use looks -like this: - -```example:single -#set document(title: [ - A Fluid Dynamic Model - for Glacier Flow -]) - -<<< ... - -#set page( ->>> "us-letter", ->>> margin: auto, - header: align( - right + horizon, - // Retrieve the document - // element's title property. - context document.title, - ), -<<< ... ->>> numbering: "1", -) ->>> #set par(justify: true) ->>> #set text(font: "Libertinus Serif", 11pt) - ->>> #show title: set text(size: 17pt) ->>> ->>> #show title: set align(center) ->>> #show title: set block(below: 1.2em) -#title() -``` -Well done! One notable thing is that we used a set rule within the content -argument of `align` to turn off justification for the abstract. This does not -affect the remainder of the document even though it was specified after the -first set rule because content blocks _scope_ styling. Anything set within a -content block will only affect the content within that block. - -Another tweak could be to remove the duplication between the header and the -title element's argument. Since they share the title, it would be convenient to -store it in a place designed to hold metadata about the document. We would then -need a way to retrieve the title in both places. The `document` element can help -us with the former: By using it in a set rule, we can store document metadata -like title, description, and keywords. - -```typ -#set document(title: [A Fluid Dynamic Model for Glacier Flow]) -``` - -When exporting a PDF, the title set here will appear in the title bar of your -PDF reader. Your operating system will also use this title to make the file -retrievable with search. Last but not least, it contributes to making your -document more accessible and is required if you choose to comply with PDF/UA, a -PDF standard focused on accessibility. - -Now, we need a way to retrieve the value we set in the main title and the -header. Because the `title` function is designed to work together with the -`document` element, calling it with no arguments will just print the title. For -the header, we will need to be more explicit: Because Typst has no way of -knowing that we want to insert the title there, we will need to tell it to do so -manually. - -Using _context,_ we can retrieve the contents of any values we have set on -elements before. When we use the `{context}` keyword, we can access any property -of any element, including the document element's title property. Its use looks -like this: +_コンテキスト_を使うと、これまでに要素へ設定した任意の値を取得できます。 +`{context}`キーワードを使用すれば、`document`要素の`title`プロパティを含め、どの要素のどのプロパティにもアクセスできます。 +次のように使用します。 ```example:single #set document(title: [ @@ -417,45 +343,40 @@ like this: >>> #lorem(600) ``` -First, notice how we called the title function with empty, round -parentheses. Because no argument was passed, it defaulted to what we set for the -document element above. The distinction between empty round and empty square -brackets is important: While empty round brackets show that you are passing -nothing, empty square brackets mean that you are passing one argument: an empty -content block. If called that way, the title would have no visible content. +まず、空の丸括弧で`title`関数を呼び出している点に注目してください。 +引数を渡していないため、上で`document`要素に設定した値がデフォルトで使用されます。 +空の丸括弧と空の角括弧の違いは重要です。 +空の丸括弧は何も渡していないことを示しますが、空の角括弧は1つの引数、つまり空のコンテンツブロックを渡していることを示します。 +空の角括弧で呼び出すと、タイトルには何も表示されません。 -Next, take a look at the header. Instead of the title in square parentheses, we -used the context keyword to access the document title. This inserted exactly -what we set above. The role of context is not limited to accessing properties: -With it, you can check if some elements are present in the document, measure the -physical dimensions of others, and more. Using context, you can build powerful -templates that react to the preferences of the end-user. +次に、ヘッダーを見てみましょう。 +角括弧内にタイトルを直接記述する代わりに、`context`キーワードを使って文書のタイトルにアクセスしています。 +これにより、上で設定した内容がそのまま挿入されます。 +コンテキストの役割は、プロパティへのアクセスだけではありません。 +文書内に特定の要素が存在するかを調べたり、別の要素の物理的な寸法を測定したりできます。 +コンテキストを使えば、利用者の設定に応じて変化する強力なテンプレートを構築できます。
-Why is the context keyword required to access element properties? +要素のプロパティにアクセスするには、なぜ`context`キーワードが必要なのでしょうか? -Normally, when we access a variable, we know exactly what its value is going to -be: +通常、変数にアクセスするときは、その値がどのような値になるか正確に分かっています。 -- The variable could be a constant built into Typst, like `[#sym.pi]` -- The variable could be defined by an argument -- The variable could be defined or overwritten in the current scope +- `[#sym.pi]`のように、変数がTypstの組み込み定数である場合 +- 変数が引数によって定義されている場合 +- 変数が現在のスコープで定義または上書きされている場合 -However, sometimes, that's not enough. In this chapter of the tutorial, we have -inserted a page header with the title. Even though we pass only one piece of -content for the header, we may want different pages to have different headers. -For example, we may want to print the chapter name or use the page number. When -we use context, we can write a single context block that tells Typst to take a -look at where it's inserted, look for the last heading, the current page number, -or anything else, and go from there. That means that the same context block, -inserted on different pages, can produce different output. +しかし、それだけでは不十分な場合があります。 +この章では、タイトルを含むページヘッダーを挿入しました。 +ヘッダーには1つのコンテンツしか渡していませんが、ページごとに異なるヘッダーを表示したいこともあります。 +例えば、章の名前を表示したり、ページ番号を使ったりしたい場合です。 +コンテキストブロックを1つ記述しておくと、Typstはそれが挿入された場所を起点に、直前の見出しや現在のページ番号などを調べて処理します。 +そのため、同じコンテキストブロックでも、挿入するページによって異なる出力を生成できます。 -For more information, read up on context [in its docs]($context) after -completing this tutorial. +詳しくは、このチュートリアルを終えた後に[コンテキストのドキュメント]($context)を参照してください。
@@ -553,9 +474,9 @@ place関数は引数として配置とコンテンツを受け取ります。 ガイドラインに従うために、見出しは中央揃えにして、小さな大文字を使わなければなりません。 `heading`関数はそのような設定を提供していないため、独自の見出しshowルールを書く必要があります。 -- A show-set rule to make headings center-aligned -- A show-set rule to make headings 13pt large and use the regular weight -- A show rule to wrap the headings in a call to the `smallcaps` function +- 見出しを中央揃えにするshow-setルール +- 見出しを13ptにし、太さを標準にするshow-setルール +- 見出し全体を`smallcaps`関数で囲むshowルール ```example:50,250,265,270 >>> #set document(title: [ @@ -624,18 +545,16 @@ place関数は引数として配置とコンテンツを受け取ります。 >>> #lorem(45) ``` -This looks great! We used show rules that apply to all headings. In the final -show rule, we applied the `smallcaps` function to the complete heading. As we -will see in the next example, we can also provide a custom rule to completely -override the default look of headings. +これで見た目が整いました! +ここでは、全ての見出しに適用されるshowルールを使用しました。 +最後のshowルールでは、見出し全体に`smallcaps`関数を適用しています。 +次の例で示すように、独自のshowルールで見出しのデフォルトの見た目を完全に上書きすることもできます。 -The only remaining problem is that all headings look the same now. The -"Motivation" and "Problem Statement" subsections ought to be italic run-in -headers, but right now, they look indistinguishable from the section headings. -We can fix that by using a `where` selector on our show rule: This is a -[method]($scripting/#methods) we can call on headings (and other elements) that -allows us to filter them by their properties. We can use it to differentiate -between section and subsection headings: +ただし、全ての見出しが同じように見えるという問題が残っています。 +「Motivation」と「Problem Statement」のサブセクションは斜体の追い込み見出しにする必要がありますが、現状ではセクションの見出しと区別できません。 +この問題は、`where`セレクターを使用すると解決できます。 +`where`は、見出しなどの要素に対して呼び出せる[メソッド]($scripting/#methods)で、プロパティに基づいて要素を絞り込めます。 +これにより、セクションとサブセクションの見出しを区別できます。 ```example:50,250,265,245 >>> #set document(title: [ @@ -708,28 +627,24 @@ between section and subsection headings: >>> #lorem(45) ``` -In this example, we first scope our previous rules to first-level headings by -using `{.where(level: 1)}` to make the selector more specific. Then, we add a -show-set rule for the second heading level. Finally, we need a show rule with a -custom function: Headings enclose their contents with a block by default. This -has the effect that the heading gets its own line. However, we want it to run -into the text, so we need to provide our own show rule to get rid of this block. - -We provide the rule with a function that takes the heading as a parameter. -This parameter is conventionally called `it`, but can have another name. The -parameter can be used as content and will just display the whole default -heading. Alternatively, when we want to build our own heading instead, we can -use its fields like `body`, `numbering`, and `level` to compose a custom look. -Here, we are just printing the body of the heading with a trailing dot and leave -out the block that the built-in show rule produces. Note that this heading will -no longer react to set rules for heading numbering and similar because we did -not explicitly use `it.numbering` in the show rule. If you are writing show -rules like this and want the document to remain customizable, you will need to -take these fields into account. +この例では、まず`{.where(level: 1)}`でセレクターをより具体的にし、先ほどのルールの適用範囲を第1レベルの見出しに限定しています。 +次に、第2レベルの見出しに適用するshow-setルールを追加します。 +最後に、独自の関数を使ったshowルールが必要です。 +デフォルトでは、見出しのコンテンツはブロックで囲まれます。 +そのため、見出しは独立した行になります。 +しかし、ここでは見出しを本文へ追い込みたいので、独自のshowルールを指定してこのブロックを取り除きます。 + +このルールには、見出しを引数として受け取る関数を指定します。 +この引数は慣例として`it`と呼ばれますが、別の名前でも構いません。 +この引数はコンテンツとして使用でき、その場合はデフォルトの見出し全体がそのまま表示されます。 +一方、独自の見出しを作る場合は、`body`、`numbering`、`level`などのフィールドを使って見た目を組み立てられます。 +ここでは、見出しの本文と末尾のピリオドだけを表示し、組み込みのshowルールが生成するブロックを省いています。 +showルールで`it.numbering`を明示的に使用していないため、この見出しには見出しの番号付けなどに関するsetルールが反映されなくなることに注意してください。 +このようなshowルールを記述し、文書を引き続きカスタマイズできるようにするには、これらのフィールドを考慮する必要があります。 これは素晴らしい! 第1レベルと第2レベルの見出しにそれぞれ選択的に適用される2つのshowルールを書きました。 -`where`セレクタを使用して、見出しをレベルでフィルタリングしました。 +`where`セレクターを使用して、見出しをレベルでフィルタリングしました。 そして、サブセクションの見出しを本文と改行せずにレンダリングしました。 また、サブセクションの見出しの最後にピリオドを自動的に追加してます。 @@ -745,16 +660,13 @@ take these fields into account. - ページはUSレターサイズとし、下中央にページ番号を付け、各ページの右上に論文のタイトルを記載 ✓ これで、全てのスタイルに準拠し、論文を学会に提出できます!完成した論文は次のようになっています。 -The finished paper + +The finished paper ## まとめ このセクションでは、ヘッダーとフッターの作成方法、関数とスコープを使用してローカルにスタイルをオーバーライドする方法、[`grid`]関数を使用してより複雑なレイアウトを作成する方法、個々の関数と文書全体のshowルールを記述する方法を学びました。 -You also learned how to access element properties with context. -また、[`where`セレクタ]($styling/#show-rules)を使用して、見出しをそのレベルによってフィルタリングする方法も学びました。 +コンテキストを使用して要素のプロパティにアクセスする方法も学びました。 +また、[`where`セレクター]($styling/#show-rules)を使用して、見出しをそのレベルによってフィルタリングする方法も学びました。 結果として論文は大成功でした! あなたはその学会にて同じ志を持つ研究者にたくさん出会い、来年同じ学会で発表したいプロジェクトを計画しています。 diff --git a/website/translation-status.json b/website/translation-status.json index 3de81be274..32463c6d9f 100644 --- a/website/translation-status.json +++ b/website/translation-status.json @@ -4,7 +4,7 @@ "/docs/tutorial/": "translated", "/docs/tutorial/writing-in-typst/": "translated", "/docs/tutorial/formatting/": "translated", - "/docs/tutorial/advanced-styling/": "partially_translated", + "/docs/tutorial/advanced-styling/": "translated", "/docs/tutorial/making-a-template/": "partially_translated", "/docs/reference/": "translated", "/docs/reference/syntax/": "translated",