官术网_书友最值得收藏!

  • LaTeX Cookbook
  • Stefan Kottwitz
  • 410字
  • 2021-07-09 21:25:01

Visualizing boxes of letters and symbols

LaTeX puts text and symbols in boxes and arranges them. There are boxes of whole paragraphs, but also of single letters and symbols. In this recipe, we will closely examine the dimensions of those boxes. We will also take a look at the spacing in between and the resulting dimensions of dynamically adjusted space. This will give us a better understanding of the typesetting.

How to do it...

We will additionally load the package lua-visual-debug. Then, we will compile the document with LuaLaTeX, as follows:

  1. Open your document or any sample file. Again, we will use the document from our first recipe in Chapter 1, The Variety of Document Types.
  2. Add the following line at the end of your preamble:
    \usepackage{lua-visual-debug}
  3. Switch to LuaLaTeX in your editor for typesetting and compile the document. Take a look at these cutouts of the output. The text has some annotations, as follows:
    How to do it...

    Formulae consist of many small boxes:

    How to do it...

Examining the boxes may give you ideas about possibly tweaking formulas. In Chapter 10, Advanced Mathematics, you can read about fine-tuning math formulas. If you don't need the box visualization lines any more, you can disable the package by commenting out or deleting the line \usepackage{lua-visual-debug}.

How it works...

We simply loaded the lua-visual-debug package, which requires LuaLaTeX because of its dependency on LuaTeX. It did all the work for us, and now we just need to understand the output:

  • LaTeX's boxes are drawn with thin borders. A zero-width box would be a red rule.
  • A filled rectangle means a kern. This is a fixed vertical or horizontal space. A positive kern is colored yellow. A negative kern is colored red.
  • Tick lines stand for glue. This means vertical or horizontal space. In contrast to kern, it can be stretched or shrunken. The lines start and end with a tick. So you can recognize places where glues are touching.
  • The blue rectangle below the base line marks a point where hyphenation is allowed.
  • A square means a penalty. This is an internal value, which TeX tries to minimize in its line-breaking algorithm. A blank square means a maximum penalty; otherwise, it's filled gray.

This visualization is intended to help you with debugging the document's typesetting.

Even if you are using pdfLaTeX, it's often possible to compile by LuaLaTeX for this purpose. Otherwise, you could debug with a simplified copy of the document part you need to debug with LuaLaTeX.

主站蜘蛛池模板: 尤溪县| 辰溪县| 葫芦岛市| 石渠县| 奈曼旗| 砚山县| 新乐市| 德江县| 卓尼县| 泰州市| 芦溪县| 聊城市| 桃园县| 临朐县| 金阳县| 沾益县| 邯郸县| 泸西县| 定襄县| 花莲县| 克什克腾旗| 台南县| 静海县| 柳河县| 尉氏县| 营山县| 吐鲁番市| 台安县| 安阳市| 通化市| 龙泉市| 开鲁县| 洛扎县| 博白县| 海宁市| 如皋市| 安泽县| 泸水县| 白朗县| 徐州市| 崇信县|