# Writing a book in chapters

In Mayhap, a book is simply a folder of documents, and each document in it is a chapter. The book keeps its chapters in an order of your own, counts its words and the words you wrote today, and holds a goal, an author and a cover.

## A folder is a book

Any folder that holds documents is a book, with nothing to set up first. Its chapters are the *.mayhap*, *.md* and *.txt* documents directly inside it. Documents in its subfolders are never chapters, so a *Notes* folder inside a book stays notes.

![The list of documents in a chapter of The Harbour Year: its four chapters with their numbers and words, and the book's words against its goal](https://mayhap.app/build/assets/book-list-CrVTH9UL.webp)

Your documents folder itself isn't a book, and neither is your home folder. Loose documents there are just documents.

A book keeps its order, its goal and its author in a hidden *.mayhap* folder inside it, beside the chapters' history. A folder elsewhere, such as one in *Downloads*, gets that hidden folder only once you do something with it as a book, like reordering its chapters.

## Making a new book

To make a book, press `Ctrl+O / ⌘O` to open the list of documents and choose *New book…*, just before *Browse…*. You may also run *New book…* from the command palette or the file menu. The list's search field becomes the book's name, with a line under it saying where the book will go, such as *return makes the book in Documents › Mayhap · esc*.

Type the name, for example *The Harbour Year*, and press `Return`. Mayhap makes the book's folder in your documents folder. If the window held an untitled document, that document becomes the book's first chapter. Otherwise, a new untitled first chapter takes its place.

## Adding chapters

To add a chapter, choose *New chapter* in the file menu, or the *New chapter* row under the chapters in the list of documents. You may also run it from the command palette. A new, untitled chapter opens at the end of the book.

You don't need to name a chapter. When you save it, Mayhap names its file after the chapter's first line, up to 60 characters, and saves it into the book without asking where. For example, a chapter that starts *The ferry left at six* is saved as *The ferry left at six.mayhap*.

To open the new chapter in a window of its own, hold `Ctrl / ⌘` while you click *New chapter* in the list, or press `Ctrl+Return / ⌘Return` on it.

## Chapters and their order

Open the list of documents from any chapter, and the book is the first group in it, titled with its name. Each chapter shows its number, its name and its words. A chapter's name is its first heading, or its file's name when it has no heading.

At first, the chapters go in the order of their names, with numbers in names counted as numbers, so *2* comes before *10*. A chapter you add later goes at the end. To change the order, drag a chapter to its place, or pick it and press `Alt+↑ / ⌥↑` or `Alt+↓ / ⌥↓`. Mayhap saves the new order at once.

A chapter keeps its place in the order whatever its file is called, even after *Rename…*.

## Moving between chapters

To open the next chapter in this window, press `Ctrl+Page Down / ⌥⌘↓`. To open the previous one, press `Ctrl+Page Up / ⌥⌘↑`. If the chapter you're leaving has unsaved changes, Mayhap asks about them first. At either end of the book, nothing happens.

You may also run *Next chapter* and *Previous chapter* from the command palette.

## Words and a goal

Under the chapters, a line counts the book's words. With a goal, it reads *19,172 of 80,000 words · today +1,240*, with a bar under it that fills as you go. Without one, it reads *19,172 words · today +1,240*.

*Today* is how many words the book has gained since Mayhap first saw it that day. If you cut more than you wrote, it says so, such as *today −120*. Chapters open in a window count as they are there, unsaved changes included.

## The book's card

Each book has a card with its cover, its name, its goal and its author. To open it, click the book's name over its chapters, or click the line with the words. You may also run *Set a goal for the book* from the command palette.

![The card of The Harbour Year with its cover, a goal of 80,000 words and its author](https://mayhap.app/build/assets/book-card-BtSsaoHW.webp)

Goal
: The number of words you're aiming for, for the whole book.

Author
: Your name as it should appear on the book. It starts with the author you last typed in any book.

Mayhap saves what you type as you type it. Press `Tab` to go from one field to the other, and `Esc` to close the card.

## The cover

Without a cover, the card's frame says *Add a cover…*. Click it and pick a PNG or JPEG image, or drop an image on the card. Mayhap copies it into the book's folder as *cover.png* or *cover.jpg*.

To change the cover, rest the mouse on it and click *Change cover…*. To take it away, right-click the cover and choose *Remove cover*, which moves the file to your system's trash.

The cover goes on the first page of the book's PDF and into its EPUB and FB2. You can learn more about this in [Exporting and sharing](https://mayhap.app/guide/sharing-and-export).

## Books in the list of documents

Under the folder you're in, the list of documents has a *Books* group: every book in your documents folder, each with how many chapters it holds. Click a book, or press `Return` on it, to open the chapter you saved last.

To see a book's chapters without opening one, press `→` on it, or click the *›* at the end of its row. The chapters show in the list's place, and you may reorder and open them there too. Press `←` or `Esc` to go back.

## Keys

| Command | Linux, Windows | macOS |
| --- | --- | --- |
| Open a document | Ctrl+O | ⌘O |
| Next chapter | Ctrl+Page Down | ⌥⌘↓ |
| Previous chapter | Ctrl+Page Up | ⌥⌘↑ |
| Move a chapter up / down | Alt+↑ / Alt+↓ | ⌥↑ / ⌥↓ |
| Other field on the card | Tab | Tab |
| Close the card | Esc | Esc |
