On Thu, 25 Jun 2026, Werner LEMBERG wrote:

> > As a workaround, I’ve drafted a simple LaTeX file to typeset a
> > paragraph for me using Knuth-Plass, with formatting identical to
> > what I use in LilyPond. I used LuaLaTeX as compiler.  Please see the
> > attached PDF.  The code is below.
>
> This is a nice idea!
>

Thank you, Werner!

I’d like to turn this LaTeX code into a snippet for the Wiki after I refine
it with help from this list.


> > I am very, very new to the world of LaTeX, so I’d like to ask the
> > LaTeX-proficient people on this list for input on my .tex code
> > (below).
>
> I think it's ok.


Thank you for looking at my draft.

Please see attached a new LilyPond file and the LilyPond output.

Below my signature is a draft of my TeX input to typeset this text. I’ve
attached the LaTeX output.

You might probably increase the line spacing in the
> LaTeX output so that comparison with LilyPond output is easier.
>

I have done so below. \setstretch{1.1} is an approximation via
“eyeballing.” Is that a good approximation of LilyPond’s line spacing?

I don’t know how I would get the *exact* same line spacing that LilyPond
uses in a default paragraph of \markup text. But I suppose that exactitude
doesn’t matter for my current purposes.

I’ve a question about paper margins. In lilypond/ly/paper-defaults-init.ly
at master
<https://github.com/lilypond/lilypond/blob/master/ly/paper-defaults-init.ly>,
I see:
  left-margin-default = 15\mm   % scaled to paper-size
  right-margin-default = 15\mm  % scaled to paper-size

When I use *letter* (8.5x11) paper, are the *default left and right
margins* still
*exactly* 15 mm?

(The default margins appear to be exactly 15 mm in my testing, but I’m not
sure whether LilyPond is doing a small amount of scaling away from 15.0000
mm.)

One more question: In my LaTeX instructions below, did I get the conversion
from \hspace (staff spaces) to millimeters right? And did I explain it
clearly?

Gabriel


*%%%  Steps to recreate the formatting of%%%  LilyPond’s \markup \justify
in LaTeX:*

*% 1. Set the font size and paper size.*
% 1a. If you are using all the defaults in LilyPond,
%     text in a \markup block is in 11pt font.
% 1b. LilyPond’s default paper size is a4paper.
%     If you use a different paper size,
%     declare it here.
\documentclass[11pt, letterpaper]{article}

*% 2. Choose your typeface.* This template
%    uses LilyPond’s default typeface.
\usepackage{fontspec}
\setmainfont{C059}

*% 3. Set the margins.* This template uses
%    LilyPond’s default margins for A4 paper.
\usepackage[
  left=15mm,
  right=15mm
]{geometry}
% See
https://github.com/lilypond/lilypond/blob/master/ly/paper-defaults-init.ly


*% 4. Declare French spacing (single space after periods)*%    to match
LilyPond’s spacing.
\frenchspacing


*% 5. Declare your paragraph indentation settings.*%    By default,
LilyPond does not indent text
%    at the beginning of a markup.
\setlength{\parindent}{0pt}


*% 6. Change \baselinestretch to%    approximate LilyPond line spacing.*
\usepackage{setspace}
\setstretch{1.1}
%%% ^ Is that a good way to approximate LilyPond???

\begin{document}

*% 7. Write the text that will go into LilyPond here:*Many LilyPond experts
say that the
best thing about LilyPond is that it
handles all layout programmatically.



*% 8. If you indent a paragraph in LilyPond,%    you should indent it in
LaTeX, too.*%    But the unit of \hspace in LilyPond is
%    the staff space, which you will need to

*%    convert to an absolute distance for LaTeX.*%    In mm, a staff space
is
%    (staff-size/4) * (2540/7227).
%    This template replicates \hspace #3
%    in a LilyPond file with all default settings
%    (i.e., a staff size of 20 points).
%    (20/4) * (2540/7227) * 3 = 5.27189705272 mm.
\setlength{\parindent}{5.27189705272mm}
This block of text contains
two paragraphs. In both paragraphs, for
testing purposes, I am using
abnormally long words.
\end{document}

Attachment: Justified Text - v2.ly
Description: application/frescobaldi-ly

Attachment: Justified Text - v2 - LilyPond Output.pdf
Description: Adobe PDF document

Attachment: Justified Text - v2 - LaTeX Output.pdf
Description: Adobe PDF document

Reply via email to