0

How can I get both justified text with no hyphenation and still even word spacing, these two might be the opposite of each other, if so tell me.

enter image description here

Also here you can see how the space between lines change. And the effect is even amplified if a lower case g is put in. How can I get even line-to-line spacing inside a paragraph.

Lastly that right side with justification and no hyphenation appears to stick out and if an f is at the end of the line the the upper part of it will stick out of the margin, How could I avoid this?

PS. The method I used for justification with no hyphenation is the following

% -------------------

\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=1000
\hbadness=1000

% -------------------

EDIT: Here's the code that Marijn asked for

% methamatics
\documentclass{article}

\usepackage{unicode-math}
\usepackage{fontspec,xltxtra}
\usepackage{lipsum}

% -------------------

\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=1000
\hbadness=1000

% -------------------

\renewcommand{\normalsize}{\fontsize{12}{7}\selectfont}

\setmathfont[]{STIX Two Math}

\setmainfont[Ligatures = {Historic}, Contextuals = Alternate, Kerning = On]{Hoefler Text Pro}

% \setmathrm
% [
%   Style = Historic,
%   Ligatures = Historic,
% ]
% {Hoefler Text Pro}

% \setmathsf
% [
%   Style = Historic,
%   Ligatures = Historic,
% ]
% {Hoefler Text Pro}

% \setboldmathrm
% [
%   Style = Historic,
%   Ligatures = Historic,
% ]
% {Hoefler Text Pro Bold}

%-CMDS

\newcommand{\tib}[1]{{\fontspec
    [
        Contextuals = LineFinal,
        Kerning = On,
    ]
    {Hoefler Text Pro Engraved One}
    \fontsize{24}{12}
    \selectfont #1 \normalfont \normalsize}}

\newcommand{\tisc}[1]{{\fontspec
    [
        Letters = SmallCaps,
        Kerning = On,
    ]
    {Hoefler Text Pro}
    \fontsize{20}{12}
    \selectfont #1 \normalfont \normalsize}}

%-DCMNT

\begin{document}


    \begin{center}

        \tib{aaaaa aaaaaaaa}\\[\baselineskip]
        \tisc{aaaaaaaaaaaaa\\
        to \\
        aaaaaaaaaaaaa} \\ 
        $$  $$

    \end{center}

    \noindent\lipsum[3]

\end{document}
  • 2
    Could you please provide a complete document (called MWE, starting with \documentclass and ending with \end{document}) that reproduces the output in your question? That makes it easier for the community to try out possible solutions. Besides that, the default behavior of the word and line spacing algorithms of LaTeX are designed for readability, are you sure you want to change that? – Marijn Nov 13 '17 at 19:40
  • The extra word spaces that you note are always at the end of sentence. This is the difference between the English \nonfrenchspacing, a bit notorius because your font settings, and the \frenchspacing when you write in French or Spanish for instance, but you can change the defaults in your preamble. – Fran Nov 13 '17 at 19:56
  • Fran, it seems that TeX defines word spacing per line, and the amount of words within a line influences it. – Suppboi Nov 13 '17 at 20:04
  • 2
    If you have no hyphenation and do not allow inter-word space to stretch then surely it is clear that you can not justify the text and you should use \raggedright – David Carlisle Nov 13 '17 at 22:21
  • 1
    your baselines are wrong because of the weird setting \fontsize{24}{12} \selectfont this tells tex to set 24pt text with a vertical baseline separation of 12pt, this is clearly impossible so it sets things as close as it can which is why lines with capitals or descenders need more space. the second argument should normally be at least 10% bigger than the first argument. – David Carlisle Nov 13 '17 at 22:25
2

I don't have the fonts to run your example, and this answer only addresses the vertical spacing, but

\newcommand{\tisc}[1]{{\fontspec
    [
        Letters = SmallCaps,
        Kerning = On,
    ]
    {Hoefler Text Pro}
    \fontsize{20}{12}
    \selectfont #1 \normalfont \normalsize}}

The final \normalfont \normalsize does nothing as it is immediately followed by the end of group which reverts the font to the font current at the start of the group so this is the same as

\newcommand{\tisc}[1]{{\fontspec
    [
        Letters = SmallCaps,
        Kerning = On,
    ]
    {Hoefler Text Pro}
    \fontsize{20}{12}
    \selectfont #1 }}

this adds a space token (from the newline after {12}) that would make space in the output if this command was used in horizontal mode, then selects the font at 24pt, and specifies a baselineskip of 12pt!! then adds the text from the argument followed by another word space (that could make an extra white line at the end of the paragraph if the linebreak happens before the final space).

As TeX applies linebreaking to a whole paragraph using the settings in force at the end, the 12pt baselineskip will not be used if the argument does not include paragraph breaks (if it does include paragraph breaks, the paragraphs before the last will be set with 12pt baselineskip, and the final paragraph will be set with whatever linespacing was in force before the command).

TeX never over-prints to force a specified linespacing, so setting 24pt text on a nominal 12pt separation will cause TeX to produce inconsistent line space with the lines being placed as close as possible (separated by \lineskip, which defaults to 1pt), so lines with larger letters will be have bigger spacing than lines with smaller letters.

So to achieve more consistent spacing you want to comment out the space tokens, specify a baselineskip that is larger than the font size, and ensure there is a paragraph end within the scope of the baseline specification.

\newcommand{\tisc}[1]{{\fontspec
    [
        Letters = SmallCaps,
        Kerning = On,
    ]
    {Hoefler Text Pro}%
    \fontsize{20}{22}\selectfont
    #1%
    \par}}
  • it did work, thanks a lot. It even allows for that weird font size and separation. – Suppboi Nov 14 '17 at 0:48
  • @Suppboi glad you got something working, note all your baseline specifications need changing not just \tis... commands eg \renewcommand{\normalsize}{\fontsize{12}{7}\selectfont} is similarly wrong. – David Carlisle Nov 14 '17 at 0:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.