1. Introduction
  2. User Guide
  3. 1. Installation
  4. 2. Get Started
  5. 3. Frequently Asked Questions
  6. 4. Further reading
  7. Reference Guide
  8. 5. Command Line Tool
    1. 5.1. init
    2. 5.2. build
    3. 5.3. serve
    4. 5.4. clean
    5. 5.5. completions
  9. 6. Format
    1. 6.1. book.typ
      1. 6.1.1. Book Metadata
        1. 6.1.1.1. Draft chapter
      2. 6.1.2. Build Metadata
    2. 6.2. Theme
    3. 6.3. Typst Support
      1. 6.3.1. Cross Reference
        1. 6.3.1.1. Cross Reference Sample
      2. 6.3.2. Embed Sanitized HTML Elements
        1. 6.3.2.1. Multimedia components
      3. 6.3.3. Semantic Page Description
    4. 6.4. Rendering Tests
  10. 7. For developers
    1. 7.1. Typst-side APIs
    2. 7.2. shiroa CLI Internals
    3. 7.3. Alternative Backends

shiroa

#

The init command

The init command will try to initialize your book to build your book successfully by default. It is hence including all of the options from build command.

For instance, Initialize a book to the directory my-book:


        
shiroa init my-book/

        
shiroa build my-book/

        
shiroa init my-book/

        
shiroa build my-book/

Initialize a book with specific typst workspace directory:


        
shiroa init -w . my-book/

        
shiroa build -w . my-book/

        
shiroa init -w . my-book/

        
shiroa build -w . my-book/

Initialize a book with specific dest-dir:


        
shiroa init --dest-dir ../dist my-book/

        
shiroa build my-book/ # memoryized dest-dir

        
shiroa init --dest-dir ../dist my-book/

        
shiroa build my-book/ # memoryized dest-dir

#

Things to note

The harder way, by creating the book without init command, your book.typ should at least provides a book-meta, as Get Started shown.


        
#import "@preview/shiroa:0.2.3": *

        
#show: book

        


        
#book-meta(

        
    title: "My Book"

        
    summary: [

        
      = My Book

        
    ]

        
)

        
#import "@preview/shiroa:0.2.3": *

        
#show: book

        


        
#book-meta(

        
    title: "My Book"

        
    summary: [

        
      = My Book

        
    ]

        
)

Your template.typ must import and respect the get-page-width and target variable from @preview/shiroa:0.2.3 to this time. The two variables will be used by the tool for rendering responsive layout and multiple targets.


        
#import "@preview/shiroa:0.2.3": get-page-width, target, is-web-target, is-pdf-target

        


        
// Metadata

        
#let page-width = get-page-width()

        
#let is-html-target = is-html-target() // target.starts-with("html")

        
#let is-pdf-target = is-pdf-target() // target.starts-with("pdf")

        
#let is-web-target = is-web-target() // target.starts-with("web") or target.starts-with("html")

        


        
#let project(body) = {

        
  // set web/pdf page properties

        
  set page(

        
    width: page-width,

        
    // for a website, we don't need pagination.

        
    height: auto,

        
  )

        
  

        
  // remove margins for web target

        
  set page(margin: (

        
    // reserved beautiful top margin

        
    top: 20pt,

        
    // Typst is setting the page's bottom to the baseline of the last line of text. So bad :(.

        
    bottom: 0.5em,

        
    // remove rest margins.

        
    rest: 0pt,

        
  )) if is-web-target;

        
  

        
  body

        
}

        
#import "@preview/shiroa:0.2.3": get-page-width, target, is-web-target, is-pdf-target

        


        
// Metadata

        
#let page-width = get-page-width()

        
#let is-html-target = is-html-target() // target.starts-with("html")

        
#let is-pdf-target = is-pdf-target() // target.starts-with("pdf")

        
#let is-web-target = is-web-target() // target.starts-with("web") or target.starts-with("html")

        


        
#let project(body) = {

        
  // set web/pdf page properties

        
  set page(

        
    width: page-width,

        
    // for a website, we don't need pagination.

        
    height: auto,

        
  )

        
  

        
  // remove margins for web target

        
  set page(margin: (

        
    // reserved beautiful top margin

        
    top: 20pt,

        
    // Typst is setting the page's bottom to the baseline of the last line of text. So bad :(.

        
    bottom: 0.5em,

        
    // remove rest margins.

        
    rest: 0pt,

        
  )) if is-web-target;

        
  

        
  body

        
}