Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)ES
Posts
16
Comments
0
Joined
2 yr. ago
TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

A Pragmatic Approach to Paragraphs, by Philip Taylor

What's your method for dealing with underfull/overfull \hboxes and unacceptable badness in general?

LaTeX has the \sloppy command which IIRC sets \tolerance to 9999, and \emergencystretch to a large value. But the default \tolerance is 200 (I think), which is a big difference. It's very "either/or" when maybe there's a more optimal way.

For my native language (swedish) I've found that many issues arise because TeX doesn't find all the possible hyphenation points, so I usually spend time adding words to the hyphenation list.

But still, in any longer text there's usually a couple of paragraphs that just won't set right, I'm curious about your tricks or methods for dealing with them.

TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

Simple font selection for opentype fonts

ConTeXt has a nice font selection system. LaTeX ported the ConTeXt code in luaotfload.sty and they have fontspec, OpTeX has a font selection system with font files and all. In plain, there's only the primitive font switches. There are some packages on ctan for plain to extend functionality, but I'm not sure how they work.

The good news is, you can use luaotfload.sty directly in plain! Just \input luaotfload.sty. The bad news if you're into minimalism is that it depends on LaTeX so you'll need that installed. An alternative is to use luafonts.tex from the csplain package: \input luafonts.tex, it uses the luaotfload code too.

Once you've done that, you can use all the nice things in luaotfload.

In this example I'll use an updated version of Tuftes Bembo-clone, ETbb. You can put the files anywhere where luaotfload will find them, ~/.fonts or your projects directory for example.

There are many ways to implement font selection. I r

TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

Quantum spaces: Designing pages on grids

This is a rather interesting presentation by Jean-Luc Doumont about placing content on a grid, or a subset of the grid. He's kind of taking this idea to the extreme.

Allmän diskussion @feddit.nu
estee @lemmy.sdf.org

Hur mår ni egentligen?

Jag har kommit in i semesterlunket men är ändå lite sliten. Oroar mig lite över saker generellt. Hemfriden och självtiden. Läste en ytterst deprimerande dikt som hette "Orissa", men den var fin på ett sätt. Blev stressad av en amerikan som pratade och skrattade för högt på ett café. På det hela taget kunde det varit värre.

LaTeX @lemmy.ca
estee @lemmy.sdf.org

Acceptable badness

I was reading an old TUGboat article about "sensible defaults" where the author set \tolerance to 250 and no \emergencystretch or \hfuzz.

Now, my columns usually end up being around 55-65 characters wide, which isn't that wide, but in any longer text I'm lucky if I can stay under badness 1000 in underfull \hboxs. Some of those can be hyphenated or otherwise manipulated away, but 250 is hard to reach.

Is this just me? I'm curious where you usually land with \tolerance and badness? (For comparison maybe also mention the width of your paragraphs?)

TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

Controlling headers and footers

The defaults for headline and footline in plain.tex is:

 undefined
    
\headline={\hfil}
\footline={\hss\tenrm\folio\hss}

  

I.e. there's no header, and in the footer the page number is printed in the center.

Many times I've found that some pages, like title pages or chapter opening pages, need exceptions from the defaults. I'd like to have a way of saying "on this page there should be neither header nor footer" or "on this page there should be a footer, but no header". Or, the header should say one thing if it's a verso page, and another if it's a recto page. In this case, we can use conditionals. They can be created like this:

 undefined
    
\newif\iffootline \footlinetrue
\newif\ifheadline \headlinetrue

  

I want the default to be to print both headline and footline, so the conditionals are set to true initially.

In this case I want to control the current page only, so if the conditional is false, it needs to change back to true for the next page. For the footline, we could have this:

 undefined
    
\footl
  
TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

EB Garamond (Duffner) initials updated

It's been around... looks at clock ...nine years since something significant happened with the EB Garamond initials, but a couple of months ago they split off into their own github repo and you can now use all the letters of the alphabet! Before, it was limited to a subset of letters.

NB, this only applies to the original Duffner EB Garamond, not the Octavio Pardo version found on Google Fonts.

If you want them, clone or download the repo, download the dependencies, and run make. Or message me and I'll send the files. It's free software so that ought to be ok.

TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

A macro to visualize boxes

There's this guy called Stephan V. Bechtolsheim who wrote a series of books on TeX called "TeX in Practice". He's really good at the finer details of, well, everything.

In one of the books, he makes a macro to visualize boxes. It's built up over many pages and chapters with lots of small macros as building blocks. Because he's reusing these macros in different places, it makes a lot of sense.

However, when I wanted to use the box visualizing macro, I found that I had to look up and copy a lot of code to make it work. This was no fun, so I re-wrote it in a "flatter" way where it's just regular plain old macros.

I ended up with this:

 undefined
    
\newdimen\linethickness \linethickness=0.4pt

\def\boxlines #1{%
    \hbox{%
        % Save original (argument) box
        \setbox0 = #1%
        % Place bullet at baseline and vertical align of the box
        \setbox1 = \hbox{\hskip -2.5pt \lower 2.5pt \hbox{$\circ$}}%
        \ht1=0pt \dp1=0pt \wd1=0pt
        \box1
        % Place a dashed line 
  
TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

A macro to prevent indentation of the next paragraph.

Sometimes it's nice to have a macro that prevents indentation of the next paragraph. For example, if you're writing your own section header macros and it's hard to automatically insert a \noindent in the right place. There's another way but it's not very intuitive:

 undefined
    
\def\firstnoindent{%
    \global\everypar={%
        \global\everypar={}%
        \setbox0=\lastbox
    }%
}

  

When I first came across this I had to pause and think about it a little.

What happens when you start a new paragraph? First you're in vertical mode, then TeX interprets some tokens as horizontal material and wants to switch over to horizontal mode. \noindent is a special horizontal material that starts an empty horizontal list, but all other material, like regular characters or horizontal glue, will first insert an \hbox of \parindent length. This is your normal paragraph indentation. Next, TeX will insert the content of \everypar, and then come your words or whatever made TeX start a paragraph

TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

How do you usually organize your source files?

I've had projects where it's just one big .tex file including all the macros and content, and projects where there's a whole file hierarchy of chapter subdirectories and layers of \inputs and macro files and... It can sort of get out of hand for me, where it makes sense in the moment and then looking at it a week later it's a puzzling labyrinth of files.

I guess it depends on the nature of the project, but do you have a go-to way that works for you in most cases?

TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

Initials/dropcaps/lettrines

There's an example of a dropcap in the TeXbook but it invokes \lineskip because of the big letter, and so makes it hard to stay on the grid. Another solution is to first skip down a few lines, place a big letter in a box of zero height, and then skip back up again and shape the paragraph with \parshape.

It could look something like this:

 undefined
    
\font\tenrm "EBGaramond12-Regular" at 10pt \tenrm
\font\tensc "EBGaramond12-Regular":+smcp; at 10pt
\font\quotefont "EBGaramond12-Regular" at 23pt
\font\dropcapfont "EBGaramond12-Regular" at 46pt

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ut cursus ipsum, feugiat accumsan mi. Pellentesque sed ante ac augue tincidunt ultricies. Mauris vehicula ipsum est, nec bibendum odio semper sit amet. Aenean fringilla purus est, ut varius enim consectetur non.

\vskip2\baselineskip
\smash{%
    \hskip0pt % F
  
TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

Colors and pictures in plain LuaTeX

As Knuths TeX had no support for colors or pictures, we have to make our own macros for that. The following macros are perhaps a bit simple, but that also means being easy to adapt to different needs and situations.

Images can be placed with an \image{

<file>

} macro. It can be preceeded with \imageheight or \imagewidth to set dimensions. If a dimension is set to 0pt, the natural size of the image is used. This is very similar to how it's done in Opmac/OpTeX.

 undefined
    
\newdimen\imagewidth \imagewidth=0pt % 0pt gives natural size of image
\newdimen\imageheight \imageheight=0pt
\newtoks\imagedir \imagedir{} % Must end with /, e.g. mypics/

\def\image#1{%
    \hbox{%
        \saveimageresource 
            \ifdim\imagewidth=0pt \else width\imagewidth\fi 
            \ifdim\imageheight=0pt \else height\imageheight\fi 
            {\the\imagedir#1}%
          \useimageresource\lastsavedimageresourceindex
    }%
}

% Example: {\imageheight=4cm \image{mypicture.png}}

  

Colors can be set like this:

 undefined
    

% Token for \a
  
TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

Two-sided documents

In a two-sided document, the margins are mirrored. This is good if the document is intended to be read as a book, where the combination of a verso and recto page is seen as a whole. Traditionally the inner margin is smaller, so that the white space in the middle (the combined inner margins) is in harmony with the outer margins.

If we first set the recto (odd) page with some margins, then we can figure out how much the type area on a verso (even) page needs to move.

Then, the idea is to insert an \hoffset-adjusting macro in the output routine before it does anything else.

In plain LuaTeX we could have this document:

 undefined
    
% Undo 1 inch origin (personal preference)
\pdfvariable horigin 0pt
\pdfvariable vorigin 0pt

% A5 paper
\pagewidth=148.5mm
\pageheight=210mm

% Inner margin
\hoffset=0.111\pagewidth

% Top margin
\voffset=0.111\pageheight

% Type area width
\hsize=0.666\pagewidth

%Type area height
\vsize=\topskip
\advance\vsize by 32\baselineskip

\tolerance=9999 % Not important fo
  
TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

Golden canon of page construction

Jan Tschichold and Raul Rosariva independently researched the layout of medieval books, and each came up with a method of construction. Rosarivas version (to the right) lends itself very well to a programmatic approach. We could implement it (in luaTeX) in a few lines like this:

 undefined
    
% Page size (proportions 2:3)
\pagewidth=150mm	
\pageheight=225mm

% Undo 1 inch origin (personal preference)
\pdfvariable horigin 0pt
\pdfvariable vorigin 0pt

% Inner margin
\hoffset=\pagewidth
\divide\hoffset by9

% Top margin
\voffset=\pageheight
\divide\voffset by9

% Type area width
\hsize=\pagewidth
\divide\hsize by9
\multiply\hsize by6

% Type area height
\vsize=\pageheight
\divide\vsize by9
\multiply\vsize by6

  

This is all well and good if we have vertically stretchable material on every page. But... if we want to do grid typesetting, we will quickly run into

TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

Modern versions of TeX

If you've read the TeXbook, you probably noticed that there are some outdated aspects of it. Most people don't use bitmap fonts or DVI anymore, they use opentype and PDF. Because of this, the engine evolved from TeX to pdfTeX, XeTeX and luaTeX. Two projects worth checking out if you are interested in a modern version of TeX, are:

OpTeX https://ctan.org/pkg/optex

Minim https://ctan.org/pkg/minim

TeX typesetting @lemmy.sdf.org
estee @lemmy.sdf.org

The TeXbook

Donald Knuths surprisingly friendly manual of the TeX macro language.

Edit: Removed the link to the pdf, which is available online in various places, because of copyright. The source is freely available to read, but not to make your own document.