- LaTeX Cookbook
- Stefan Kottwitz
- 685字
- 2021-07-09 21:25:01
Typesetting in a grid
Besides full horizontal justification, LaTeX also adjusts the page content vertically to get a consistent page height. So, internal spacing is often variable. Furthermore, implicit spaces are often independent of the baseline height.
Consequently, lines of adjacent pages may look shifted. For two-sided prints with very thin paper, matching base lines would look much better. Especially in two-column documents it may be desirable to have baselines of adjacent lines at exactly the same height.
In this recipe, we would like to arrange lines on a grid. Normal text lines will be placed at a baseline grid. Displayed formulas, figures, tables, and captions are allowed to have a different baseline, but the following text should return to the grid.
How it works...
We specified the font size and the base line height as options to the grid
package because the default settings don't look right.
The grid
package makes some changes that helps the lines to stay in the grid. This is how it works:
- So-called glue, also known as rubber space, which is elastic space, is removed or replaced by a fixed space.
- The heights of many frequently-used items were made integral multiples of the baseline height so that they would fit exactly to the grid. This has been made, for example, for the following:
- Section headings
- Figures and tables
- Displayed equations
We did this here, and got a quick solution for double-column grid typesetting, at least in a limited way. For example, we need to accept the changed section heading size.
There's more...
The gridset
package provides a command, \vskipnextgrid
, which jumps the next grid position. It can be used as a simple fix, without being a complete solution. It requires two or more typesetting runs until all is adjusted. So you need to look at the affected place and repeat compiling if needed, especially if you use \vskipnextgrid
repeatedly.
This command can also be used in addition to the grid
package. In a case where the grid
package might fail, we can correct this by inserting the \vskipnextgrid
command.
For example the amsmath
package's multiline displayed equations could be a problem for the grid
package. We can fix this as follows:
- Load
amsmath
using the following command:\usepackage{amsmath}
- Also load the
gridset
package by using the following command:\usepackage{gridset}
- In the document, create an
align
environment, as follows:\begin{align} y &= \sum_{n=1}^3 f(n) \\ &= f(1) + f(2) + f(3) \end{align}
- Directly after it, add the following line. It ends the paragraph, skips to the next position in the grid, and avoids inserting paragraph indentations:
\par\vskipnextgrid\noindent
- Add some text following it.
- Compile the document once. The position of the previously-added text may still not yet fit the grid.
- Compile again. The
\vskipnextgrid
command will again adjust the spacing to match the base line grid.
The \vskipnextgrid
command may have problems in two-column mode. In this case, we fixed it by breaking the paragraph, adjusting the position, and suppressing the following paragraph indentation, because that is unusual after a displayed formula.
- Functional Python Programming
- SPSS數據挖掘與案例分析應用實踐
- Python程序設計教程(第2版)
- 精通JavaScript+jQuery:100%動態網頁設計密碼
- 大學計算機基礎實驗教程
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- MySQL數據庫應用與管理 第2版
- 樂高機器人設計技巧:EV3結構設計與編程指導
- PhoneGap:Beginner's Guide(Third Edition)
- Android系統級深入開發
- Hands-On Full Stack Development with Spring Boot 2.0 and React
- 超簡單:用Python讓Excel飛起來(實戰150例)
- SSH框架企業級應用實戰
- 零基礎學Java第2版
- Responsive Web Design with jQuery