| 1 |
<!-- Copyright (C) 2023-2025 by Jinwen XU --> |
| 2 |
|
| 3 |
# `jwjournal`, a personal LaTeX class for writing journals |
| 4 |
|
| 5 |
> Package dependencies: [`enumitem`](https://ctan.org/pkg/enumitem), [*`einfart`*](https://ctan.org/pkg/minimalist), [`minimalist`](https://ctan.org/pkg/minimalist), [`needspace`](https://ctan.org/pkg/needspace), [`projlib`](https://ctan.org/pkg/projlib), [`tcolorbox`](https://ctan.org/pkg/tcolorbox). |
| 6 |
|
| 7 |
## Introduction |
| 8 |
|
| 9 |
A typical journal entry produced by `jwjournal` looks like this: |
| 10 |
 |
| 11 |
|
| 12 |
Codewise, it is as simple as below: |
| 13 |
``` |
| 14 |
2023-01-01 Sunny | Botanical Garden |
| 15 |
|
| 16 |
Today I visited the botanical garden! |
| 17 |
|
| 18 |
[Food] And had *ice cream* for lunch! |
| 19 |
|
| 20 |
>>> This botanical garden has a history of nearly two hundred years, take a look at this photo: |
| 21 |
|| <0.40> {example-image} |
| 22 |
|
| 23 |
(( <0.45> {example-image-a} |
| 24 |
<- <5> |
| 25 |
)) <0.50> {example-image-b} |
| 26 |
<- <5> |
| 27 |
(( <0.45> {example-image-c} |
| 28 |
``` |
| 29 |
|
| 30 |
> It is also possible to write the date with other separators, such as `2023/01/01` or `2023.01.01`. |
| 31 |
|
| 32 |
> With the options `month-day-year` or `day-month-year`, you can also write date in the format `mm-dd-yyyy` or `dd-mm-yyyy`, respectively. You may refer to the English, French and German demo documents for examples. |
| 33 |
|
| 34 |
Every day of the week has its unique color, like this: |
| 35 |
 |
| 36 |
|
| 37 |
By the way, the conversion from plain date string like `2023-01-01` to natural language like `January 1, 2023 ⬦ Sunday` is done by `jwjournal` automatically and has multilingual support. Thus, for example (via `\UseLanguage`): |
| 38 |
- Chinese:  |
| 39 |
- French:  |
| 40 |
- German:  |
| 41 |
- Japanese:  |
| 42 |
- Spanish:  |
| 43 |
- ... and more... |
| 44 |
|
| 45 |
## Usage |
| 46 |
|
| 47 |
The structure of the document is very simple: |
| 48 |
```latex |
| 49 |
\documentclass[11pt, paperstyle = light yellow, color entry, use indent = false]{jwjournal} |
| 50 |
\UseLanguage{⟨language⟩} % For English this line can be omitted. |
| 51 |
\begin{document} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
% Your journal |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
\end{document} |
| 60 |
``` |
| 61 |
The available class options include: |
| 62 |
- `month-day-year` or `day-month-year` for using other date format; |
| 63 |
- `paperstyle = ...` adjusts the paper color, choices include: `light yellow`, `yellow`, `parchment`, `green`, `light gray`, `gray`, `nord`, `dark`... |
| 64 |
- `color entry` adds more color to the title of each entry; |
| 65 |
- `scroll` turns the scroll mode on, which generates a single-page pdf similar to a long screenshot. |
| 66 |
|
| 67 |
> There are also some relevant options provided by the base class of `jwjournal`: |
| 68 |
> - `use indent = false`: disable the paragraph indentation and add some space between each paragraph instead. |
| 69 |
> - `use style = ⟨provided style⟩`: select the designing style of the current article; for our purpose here, it is recommended to use the style `classical` (with this the option `use indent = false` is added by default), together with the options `title in boldface` and `title in sffamily`, see the comment below regarding the usage of "Section". |
| 70 |
> |
| 71 |
> You may refer to the demo documents to see their actual usage. |
| 72 |
|
| 73 |
Here are the major syntaxes for your main text: |
| 74 |
1) Title |
| 75 |
- Any line begins with date like `2023-01-01` or `2023/01/01` would be regard as the *Title* line. |
| 76 |
- You may write the weather and/or location after the date. |
| 77 |
- Example: |
| 78 |
``` |
| 79 |
2023-01-01 Sunny | Apartment |
| 80 |
``` |
| 81 |
> With the options `month-day-year` or `day-month-year`, you can also write date in the format `mm-dd-yyyy` or `dd-mm-yyyy`, respectively. You may refer to the English, French and German demo documents for examples. |
| 82 |
1) Note |
| 83 |
- Any line begins with something like `[Note]` would be regard as the *Note* line. |
| 84 |
- Example: |
| 85 |
``` |
| 86 |
[Note] In hindsight, it was the right decision. |
| 87 |
``` |
| 88 |
The space(s) between `[Note]` and the text following it would be ignored. |
| 89 |
> You may also use `【` and `】`, which is especially useful when writing Chinese. |
| 90 |
1) Emphasis |
| 91 |
- You may emphasize text as with Markdown: |
| 92 |
- `*⟨text⟩*` is emphasizing; |
| 93 |
- `**⟨text⟩**` is bolding; |
| 94 |
- `***⟨text⟩***` is bolding and emphasizing. |
| 95 |
- You may put text in a colored block via `>>>`, its usage is like the `>` in Markdown for blockquote. |
| 96 |
1) Image |
| 97 |
- Displayed images can be included via one of the following ways: |
| 98 |
- `|| <⟨width⟩> {⟨image file name⟩}` or `|| {⟨image file name⟩} <⟨width⟩>`: show image in the middle. |
| 99 |
- `(( <⟨width⟩> {⟨image file name⟩}` or `(( {⟨image file name⟩} <⟨width⟩>`: show image on the left. |
| 100 |
- `)) <⟨width⟩> {⟨image file name⟩}` or `)) {⟨image file name⟩} <⟨width⟩>`: show image on the right. |
| 101 |
> The `<⟨width⟩>` is optional. Here `⟨width⟩` is a number like `0.75`, the unit is `\linewidth`. When `<⟨width⟩>` is not given, the width would be full `\linewidth`. |
| 102 |
1) Code |
| 103 |
> Due to the current method of implementation, it is unfortunate that one cannot directly insert source code in the document. There are some workarounds though, as described below. |
| 104 |
- For *inline* code: you may simply write it between two backticks `` `⟨code⟩` ``, similar to the Markdown syntax. However, be aware that special characters need to be escaped, for example, `\` should be written as `\textbackslash`, `{` should be written as `\{`, `%` should be written as `\%`, etc. |
| 105 |
- For *displayed* code: **this feature is not yet complete.** |
| 106 |
<!-- - For *displayed* code: store the code into a separate file, and then use `== {⟨file name⟩}` to print it. You may also use an optional argument like `== [⟨language⟩] {⟨file name⟩}` to select the language of your code. --> |
| 107 |
1) Section |
| 108 |
- You may start a new (*unnumbered*) |
| 109 |
- section, via `## {⟨section title⟩}`; |
| 110 |
- subsection, via `### {⟨subsection title⟩}`; |
| 111 |
- subsubsection, via `#### {⟨subsubsection title⟩}`. |
| 112 |
- If you wish to use the *numbered* version, write `##+`, `###+` and `####+` instead. |
| 113 |
> It is recommanded to use the class option `title in boldface`, `title in sffamily` and `use style = classical` (these options are provided by the base class of `jwjournal`). If you also wish your section title to be in small caps shape, then you may put the `⟨section title⟩` in `\textsc`. |
| 114 |
|
| 115 |
<!-- > Due to the current implementation of the emphasizing `*⟨text⟩*`, you cannot put two `##*`, `###*` or `####*` in the same paragraph — but this shouldn't be any problem, just put an empty line between any two sectional commands. --> |
| 116 |
1) Subfile |
| 117 |
- With this feature you may organize your journals in a systematic way by putting the fragments of it into subfiles distributed in separate folders. For example, you may have each folder's name to be the year, and within a folder you may have `.tex` files named after each month. |
| 118 |
- You may include a subfile containing journal text in one of the following ways: |
| 119 |
- `:: {⟨file name⟩}` for input, similarly as `\input`. |
| 120 |
- `::: {⟨file name⟩}` for include, similarly as `\include`. |
| 121 |
> Explicitly, these are `\InputJournal` and `\IncludeJournal`. If in the preamble you wish to define some automatic processing involving input or inclusion of subfiles, please use these two commands. |
| 122 |
|
| 123 |
With a few more for icing on the cake: |
| 124 |
- `|`: The first vertical bar would be interpreted as `\hfill`. This allows you to write the title line as |
| 125 |
``` |
| 126 |
2023-01-01 Sunny | Botanical Garden |
| 127 |
``` |
| 128 |
and then the address `Botanical Garden` would be printed at the end of the title line. |
| 129 |
- `\\` and `//`: `\\` has its usual meaning in LaTeX for starting a new line, while `//` has been defined to be starting a new line with some vertical spacing. This allows you to write the annotations as: |
| 130 |
``` |
| 131 |
[Note] Some text. |
| 132 |
// |
| 133 |
More text. |
| 134 |
// |
| 135 |
(Some remark) |
| 136 |
\\ |
| 137 |
(Another remark) |
| 138 |
\\ |
| 139 |
(Final remark) |
| 140 |
``` |
| 141 |
As a result, all the text would be properly indented. |
| 142 |
> Note that images specified via `||`, `((` or `))` already contain line breaks, thus you don't need to (actually, *you can't*) write `//` or `\\` around them. |
| 143 |
- `>>`: Text after `>>` would be centered. This is intended for writing annotations/captions for displayed images: |
| 144 |
``` |
| 145 |
|| {image-name} |
| 146 |
>> (Some remark) |
| 147 |
>> (Another remark) |
| 148 |
``` |
| 149 |
- `~~`: If you use `>>` or `>>>` inside a Note block (i.e. lines start with `[...]`), then there would no way to get out of the centered or boxed area and then continue the indented text; in such cases, you may start a new paragraph that start with `~~`, this will continue the indented text block: |
| 150 |
``` |
| 151 |
[Test] Here is some text. |
| 152 |
|| {some-image} <.4> |
| 153 |
>> (Centered text) |
| 154 |
|
| 155 |
~~ |
| 156 |
Some more text. |
| 157 |
>>> Text in color box. |
| 158 |
|
| 159 |
~~ |
| 160 |
And more text. |
| 161 |
``` |
| 162 |
- `->` and `<-`: Skip or retrieve certain vertical space, by default half of `\baselineskip`. You may specify the exact spacing in the unit of `\baselineskip`: for example, `-> <0.3>` would be skipping `0.3\baselineskip`, while `<- <.75>` means retrieving `0.75\baselineskip`. |
| 163 |
- `---`: Three or more hyphen chars `-` in a separate paragraph would be interpreted as a separation line (as with Markdown). |
| 164 |
- `+++`: If a single sentence or a few words fall to the next page, you may write a `+++` before that entry to enlarge the current page by one line. |
| 165 |
> You may write this `+++` several times if necessary, but do make sure that the number of the `+` sign is a multiple of 3. |
| 166 |
- `===`: Three or more equal signs `=` would simply be ignored. This is for improving the readability of the code, allowing you to write your journal like: |
| 167 |
``` |
| 168 |
2023-01-01 Sunny | Botanical Garden |
| 169 |
=================================== |
| 170 |
|
| 171 |
Today I visited the botanical garden! |
| 172 |
|
| 173 |
[Food] And had ice-cream for lunch! |
| 174 |
``` |
| 175 |
|
| 176 |
> You may also refer to the demo documents to see their behaviors in action. |
| 177 |
|
| 178 |
> And don't forget that you are still using LaTeX! Thus if the provided syntax does not satisfy you, there are always LaTeX commands as a fallback. |
| 179 |
|
| 180 |
Indentations are not important, but paragraphs need to be separated by a blank line. For the sake of readability, it is recommended to organize your text as one of the following ways: |
| 181 |
- with indentation: |
| 182 |
``` |
| 183 |
2023-01-01 |
| 184 |
Sunny | Botanical Garden |
| 185 |
|
| 186 |
...... |
| 187 |
...... |
| 188 |
``` |
| 189 |
- with a separation line: |
| 190 |
``` |
| 191 |
2023-01-01 Sunny | Botanical Garden |
| 192 |
=================================== |
| 193 |
|
| 194 |
...... |
| 195 |
...... |
| 196 |
``` |
| 197 |
- or maybe even: |
| 198 |
``` |
| 199 |
========== |
| 200 |
2023-01-01 Sunny | Botanical Garden |
| 201 |
========== |
| 202 |
|
| 203 |
...... |
| 204 |
...... |
| 205 |
``` |
| 206 |
|
| 207 |
## TeXnical details |
| 208 |
|
| 209 |
### Engines and base classes |
| 210 |
- With pdfLaTeX, the base class is `minimart`. |
| 211 |
- With XeLaTeX or LuaLaTeX, the base class is `einfart`. |
| 212 |
|
| 213 |
### Regarding the fonts |
| 214 |
|
| 215 |
If you are using XeLaTeX or LuaLaTeX to compile your document, then the current document class requires the following open-source fonts that are not included in the standard TeX collection: |
| 216 |
|
| 217 |
- The Source Han font series at [Adobe Fonts](https://github.com/adobe-fonts). More specifically: |
| 218 |
- Source Han Serif, [go to its Release page](https://github.com/adobe-fonts/source-han-serif/releases). |
| 219 |
- Source Han Sans, [go to its Release page](https://github.com/adobe-fonts/source-han-sans/releases). |
| 220 |
- Source Han Mono, [go to its Release page](https://github.com/adobe-fonts/source-han-mono/releases). |
| 221 |
> It is recommended to download the Super-OTC version, so that the total download size would be smaller, and the installation would be easier. |
| 222 |
|
| 223 |
These are necessary if you wish to write your document in Chinese (either simplified or traditional) or Japanese. Also, without these fonts installed, the compilation speed might be much slower — the compilation would still pass, but the system shall spend (quite) some time verifying that the fonts are indeed missing before switching to the fallback fonts. |
| 224 |
|
| 225 |
### Colors |
| 226 |
The colors from Monday to Sunday have the internal names `jwjournal-color-1`, ..., `jwjournal-color-7`. Currently they are defined as: |
| 227 |
```latex |
| 228 |
\colorlet { jwjournal-color-1 } { yellow!50!green } |
| 229 |
\colorlet { jwjournal-color-2 } { yellow!70!orange } |
| 230 |
\colorlet { jwjournal-color-3 } { cyan!70!blue } |
| 231 |
\colorlet { jwjournal-color-4 } { violet } |
| 232 |
\colorlet { jwjournal-color-5 } { yellow!40!cyan } |
| 233 |
\colorlet { jwjournal-color-6 } { yellow!20!orange } |
| 234 |
\colorlet { jwjournal-color-7 } { red!20!orange } |
| 235 |
``` |
| 236 |
|
| 237 |
### Functionality |
| 238 |
The main features are achieved with the power of LaTeX3's regex functionality. It scans the content paragraph by paragraph and converts recognized patterns into corresponding TeX commands. Thus, `2023-01-01 Weather` becomes `\JWJournalEntry{2023-01-01}{Weather}`, `[Note] ...` becomes `\item[Note] ...` inside a `description` environment, and `+++` is essentially `\enlargethispage{\baselineskip}`, etc. However, this comes with a price: in order to scan the content, it is firstly stored in a macro `\g_jwjournal_content_tl`, and that means that you cannot use commands like `\verb` in your main text (unless explicitly `\end{jwjournal}`, write your code, and then `\begin{jwjournal}`). |
| 239 |
Also, synctex won't work properly. |
| 240 |
|
| 241 |
### Dates |
| 242 |
The conversion of date string to natural language, and the calculation of the day of the week are accomplished by `projlib-date`, part of the `ProjLib` toolkit, which is still at its early stage, in some aspects not as functional as existing package such as `datenumber`, but should evolve through time. |
| 243 |
|
| 244 |
### Language and date format |
| 245 |
Language and date format can both be set in two ways: as class option or with corresponding commands. |
| 246 |
- The user-level command for setting language is `\UseLanguage`, provided by `projlib-language`; the one for setting date format is `\SetDatetimeInputFormat`, provided by `projlib-date`. |
| 247 |
- When you set the language, it is not exactly the same using class option or using command: when you select a language via class option, only the setting for this language would be loaded; however, with `\UseLanguage`, it would load *all* the language settings and then switch to your selected one. Sometimes the page breaking behavior differs slightly. Personally I prefer the `\UseLanguage` approach, for this would allow you to switch language in the middle of your document. |
| 248 |
|
| 249 |
### Scroll mode |
| 250 |
The scroll mode is achieved by directly accessing `\pdfpageheight` (pdfTeX and XeTeX) or `\pageheight` (LuaTeX). The minimal page height is set to be `10in`. It is worth noting that in order to calculate the height needed, the entire content are put into a single box, which puts a limitation on the length of your document (but this usually wouldn't be a problem). |
| 251 |
|
| 252 |
|
| 253 |
## Acknowledgement |
| 254 |
|
| 255 |
The author would like to thank his friend Junzhuo Zhao for his valuable help with the German language. Danke schön! |
| 256 |
|
| 257 |
|
| 258 |
## License |
| 259 |
|
| 260 |
This work is released under the LaTeX Project Public License, v1.3c or later. |