Å¿ (long s) and hyphenation

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
13
down vote

favorite
2












I'm using UTF-8 so it is – if one is using the right font – no problem to implement the different types of s in older German texts (s, ſ, ß). Unfortunately the hyphenation breaks because LaTeX does not know that ſ has to be dealt with just the same as it would do when dealing with "s".



MWE:



documentclassarticle
usepackage[ngerman]babel

begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft

hyphenationGe-Å¿ell-Å¿chaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft

enddocument


As one can see at the end of the line, I have to add the correct hyphenation manually. Any idea how I can solve this?



enter image description here







share|improve this question


















  • 2




    you could make this work automatically in luatex or xetex but in pdftex the best you could do is define Å¿ to always allow a hyphenation after it, it can not take part in patterns or hyphenation
    – David Carlisle
    Aug 6 at 14:45






  • 4




    your choices would be essentially to (a) use hyphenation as you have done for all necessary words or (b) copy the hyphenation patterns adding patterns for long s to match those for s and rebuild the xelatex format (lulatex does not need to be rebuilt) or (c) use s in the original markup and then set up font features (perhaps...) so that some s get typeset using the long form. Which would you prefer? (the last probably depends on the font you use)
    – David Carlisle
    Aug 6 at 15:29










  • I use XeLaTeX, so copying the patterns is definitely the way to go. I'll look it up, right now I'm not sure how it works. (c) is a creative solution but does not work as I have parts where I want the long s and parts were I don't as I have to stay true to the source
    – Martin Mueller
    Aug 6 at 15:37










  • oh or if you are using luatex then (d) implement a Lua hyphenation callback that hyphenates using s, then switches to long s and re-inserts the hyphenation points,
    – David Carlisle
    Aug 6 at 15:37










  • If the list of problematic patterns is short, in luatex you can also add them with babelpatterns in the document itself.
    – Javier Bezos
    Aug 6 at 17:38














up vote
13
down vote

favorite
2












I'm using UTF-8 so it is – if one is using the right font – no problem to implement the different types of s in older German texts (s, ſ, ß). Unfortunately the hyphenation breaks because LaTeX does not know that ſ has to be dealt with just the same as it would do when dealing with "s".



MWE:



documentclassarticle
usepackage[ngerman]babel

begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft

hyphenationGe-Å¿ell-Å¿chaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft

enddocument


As one can see at the end of the line, I have to add the correct hyphenation manually. Any idea how I can solve this?



enter image description here







share|improve this question


















  • 2




    you could make this work automatically in luatex or xetex but in pdftex the best you could do is define Å¿ to always allow a hyphenation after it, it can not take part in patterns or hyphenation
    – David Carlisle
    Aug 6 at 14:45






  • 4




    your choices would be essentially to (a) use hyphenation as you have done for all necessary words or (b) copy the hyphenation patterns adding patterns for long s to match those for s and rebuild the xelatex format (lulatex does not need to be rebuilt) or (c) use s in the original markup and then set up font features (perhaps...) so that some s get typeset using the long form. Which would you prefer? (the last probably depends on the font you use)
    – David Carlisle
    Aug 6 at 15:29










  • I use XeLaTeX, so copying the patterns is definitely the way to go. I'll look it up, right now I'm not sure how it works. (c) is a creative solution but does not work as I have parts where I want the long s and parts were I don't as I have to stay true to the source
    – Martin Mueller
    Aug 6 at 15:37










  • oh or if you are using luatex then (d) implement a Lua hyphenation callback that hyphenates using s, then switches to long s and re-inserts the hyphenation points,
    – David Carlisle
    Aug 6 at 15:37










  • If the list of problematic patterns is short, in luatex you can also add them with babelpatterns in the document itself.
    – Javier Bezos
    Aug 6 at 17:38












up vote
13
down vote

favorite
2









up vote
13
down vote

favorite
2






2





I'm using UTF-8 so it is – if one is using the right font – no problem to implement the different types of s in older German texts (s, ſ, ß). Unfortunately the hyphenation breaks because LaTeX does not know that ſ has to be dealt with just the same as it would do when dealing with "s".



MWE:



documentclassarticle
usepackage[ngerman]babel

begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft

hyphenationGe-Å¿ell-Å¿chaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft

enddocument


As one can see at the end of the line, I have to add the correct hyphenation manually. Any idea how I can solve this?



enter image description here







share|improve this question














I'm using UTF-8 so it is – if one is using the right font – no problem to implement the different types of s in older German texts (s, ſ, ß). Unfortunately the hyphenation breaks because LaTeX does not know that ſ has to be dealt with just the same as it would do when dealing with "s".



MWE:



documentclassarticle
usepackage[ngerman]babel

begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft

hyphenationGe-Å¿ell-Å¿chaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft

enddocument


As one can see at the end of the line, I have to add the correct hyphenation manually. Any idea how I can solve this?



enter image description here









share|improve this question













share|improve this question




share|improve this question








edited Aug 6 at 15:20









David Carlisle

463k3810861803




463k3810861803










asked Aug 6 at 14:38









Martin Mueller

428211




428211







  • 2




    you could make this work automatically in luatex or xetex but in pdftex the best you could do is define Å¿ to always allow a hyphenation after it, it can not take part in patterns or hyphenation
    – David Carlisle
    Aug 6 at 14:45






  • 4




    your choices would be essentially to (a) use hyphenation as you have done for all necessary words or (b) copy the hyphenation patterns adding patterns for long s to match those for s and rebuild the xelatex format (lulatex does not need to be rebuilt) or (c) use s in the original markup and then set up font features (perhaps...) so that some s get typeset using the long form. Which would you prefer? (the last probably depends on the font you use)
    – David Carlisle
    Aug 6 at 15:29










  • I use XeLaTeX, so copying the patterns is definitely the way to go. I'll look it up, right now I'm not sure how it works. (c) is a creative solution but does not work as I have parts where I want the long s and parts were I don't as I have to stay true to the source
    – Martin Mueller
    Aug 6 at 15:37










  • oh or if you are using luatex then (d) implement a Lua hyphenation callback that hyphenates using s, then switches to long s and re-inserts the hyphenation points,
    – David Carlisle
    Aug 6 at 15:37










  • If the list of problematic patterns is short, in luatex you can also add them with babelpatterns in the document itself.
    – Javier Bezos
    Aug 6 at 17:38












  • 2




    you could make this work automatically in luatex or xetex but in pdftex the best you could do is define Å¿ to always allow a hyphenation after it, it can not take part in patterns or hyphenation
    – David Carlisle
    Aug 6 at 14:45






  • 4




    your choices would be essentially to (a) use hyphenation as you have done for all necessary words or (b) copy the hyphenation patterns adding patterns for long s to match those for s and rebuild the xelatex format (lulatex does not need to be rebuilt) or (c) use s in the original markup and then set up font features (perhaps...) so that some s get typeset using the long form. Which would you prefer? (the last probably depends on the font you use)
    – David Carlisle
    Aug 6 at 15:29










  • I use XeLaTeX, so copying the patterns is definitely the way to go. I'll look it up, right now I'm not sure how it works. (c) is a creative solution but does not work as I have parts where I want the long s and parts were I don't as I have to stay true to the source
    – Martin Mueller
    Aug 6 at 15:37










  • oh or if you are using luatex then (d) implement a Lua hyphenation callback that hyphenates using s, then switches to long s and re-inserts the hyphenation points,
    – David Carlisle
    Aug 6 at 15:37










  • If the list of problematic patterns is short, in luatex you can also add them with babelpatterns in the document itself.
    – Javier Bezos
    Aug 6 at 17:38







2




2




you could make this work automatically in luatex or xetex but in pdftex the best you could do is define Å¿ to always allow a hyphenation after it, it can not take part in patterns or hyphenation
– David Carlisle
Aug 6 at 14:45




you could make this work automatically in luatex or xetex but in pdftex the best you could do is define Å¿ to always allow a hyphenation after it, it can not take part in patterns or hyphenation
– David Carlisle
Aug 6 at 14:45




4




4




your choices would be essentially to (a) use hyphenation as you have done for all necessary words or (b) copy the hyphenation patterns adding patterns for long s to match those for s and rebuild the xelatex format (lulatex does not need to be rebuilt) or (c) use s in the original markup and then set up font features (perhaps...) so that some s get typeset using the long form. Which would you prefer? (the last probably depends on the font you use)
– David Carlisle
Aug 6 at 15:29




your choices would be essentially to (a) use hyphenation as you have done for all necessary words or (b) copy the hyphenation patterns adding patterns for long s to match those for s and rebuild the xelatex format (lulatex does not need to be rebuilt) or (c) use s in the original markup and then set up font features (perhaps...) so that some s get typeset using the long form. Which would you prefer? (the last probably depends on the font you use)
– David Carlisle
Aug 6 at 15:29












I use XeLaTeX, so copying the patterns is definitely the way to go. I'll look it up, right now I'm not sure how it works. (c) is a creative solution but does not work as I have parts where I want the long s and parts were I don't as I have to stay true to the source
– Martin Mueller
Aug 6 at 15:37




I use XeLaTeX, so copying the patterns is definitely the way to go. I'll look it up, right now I'm not sure how it works. (c) is a creative solution but does not work as I have parts where I want the long s and parts were I don't as I have to stay true to the source
– Martin Mueller
Aug 6 at 15:37












oh or if you are using luatex then (d) implement a Lua hyphenation callback that hyphenates using s, then switches to long s and re-inserts the hyphenation points,
– David Carlisle
Aug 6 at 15:37




oh or if you are using luatex then (d) implement a Lua hyphenation callback that hyphenates using s, then switches to long s and re-inserts the hyphenation points,
– David Carlisle
Aug 6 at 15:37












If the list of problematic patterns is short, in luatex you can also add them with babelpatterns in the document itself.
– Javier Bezos
Aug 6 at 17:38




If the list of problematic patterns is short, in luatex you can also add them with babelpatterns in the document itself.
– Javier Bezos
Aug 6 at 17:38










2 Answers
2






active

oldest

votes

















up vote
9
down vote



accepted










For LuaTeX here is an implementation of David Carlisles idea to create a hypenate callback. It works by replacing every Å¿ with a marked s before hyphenation and then recovering the original characters after hyphenation:



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local sattr = luatexbase.new_attribute("longsattr")
local disc = node.id'disc'
print('DISC', disc)

local function long_to_s(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
print(n)
long_to_s(n.pre)
long_to_s(n.post)
long_to_s(n.replace)
end
if n.char == 383 then
n.char = 115
node.set_attribute(n, sattr, 383)
end
end
end
local function s_to_long(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
s_to_long(n.pre)
s_to_long(n.post)
s_to_long(n.replace)
end
local a = node.get_attribute(n, sattr)
if a then
n.char = a
node.unset_attribute(n, sattr)
end
end
end
local function myhyph(head, tail)
long_to_s(head, tail)
lang.hyphenate(head, tail)
s_to_long(head, tail)
end
luatexbase.add_to_callback("hyphenate",myhyph,"hyphenate with modified s")
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here



LuaTeX also allows you to manipulate the hyphenation pattern during a run, so you can also use (this is an automated version of David Carlisles choice (b)):



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local l = lang.new(tex.language)
l:patterns(l:patterns():gsub('s', 'Å¿'))
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here






share|improve this answer


















  • 1




    +1 thanks :-)..
    – David Carlisle
    Aug 6 at 17:44










  • I accept this answer as it seems a clever solution (even though, for other reasons, I stick to XeLaTeX)
    – Martin Mueller
    Aug 7 at 8:37

















up vote
2
down vote













A simple way to do this is to choose a font that supports Å¿ as an open type character variant, e.g., EB Garamond. Then you can just select that variant when you need it.



(Re-reading the comments above, I see this corresponds to option (c) from David Carlisle, which you said wasn't suitable, but this MWE shows you can have both kinds of s with this method.)



Update showing iſt and ſelbes.



documentclassarticle
usepackage[ngerman]babel
babelfontrmEB Garamond
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

addfontfeatureCharacterVariant=1

XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

ist selbes
enddocument


enter image description here






share|improve this answer






















  • You're right about the font. Though dis is not exactly David Carlisles option c and is no proper way to do it, because though all Å¿ are s, not all s are Å¿. The rule is, i think, that at the beginning of a word and in between letters it's an Å¿ – if not a long vocal is right before it. So it's »iÅ¿t« and »Å¿elbes«.
    – Martin Mueller
    Aug 7 at 8:36










  • @MartinMueller, EB Garamond does not change it at the end of a word, but I think it changes it everywhere else. I'm not a German speaker though, so I do not know what it should be.
    – David Purton
    Aug 7 at 8:44










  • Thank you for pointing that out. I've installed the EB Garamond but unfortunately the rules of Å¿ are far more complex than I knew (see wikipedia) and using your method does not produce the desired result. E.g. lesbisch should be lesbiÅ¿ch but is rendered leÅ¿biÅ¿ch
    – Martin Mueller
    Aug 7 at 12:20










  • @MartinMueller, that's a pity! The EB Garamond manual does warn that this feature isn't all that clever.
    – David Purton
    Aug 7 at 12:30











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f444847%2f%25c5%25bf-long-s-and-hyphenation%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
9
down vote



accepted










For LuaTeX here is an implementation of David Carlisles idea to create a hypenate callback. It works by replacing every Å¿ with a marked s before hyphenation and then recovering the original characters after hyphenation:



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local sattr = luatexbase.new_attribute("longsattr")
local disc = node.id'disc'
print('DISC', disc)

local function long_to_s(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
print(n)
long_to_s(n.pre)
long_to_s(n.post)
long_to_s(n.replace)
end
if n.char == 383 then
n.char = 115
node.set_attribute(n, sattr, 383)
end
end
end
local function s_to_long(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
s_to_long(n.pre)
s_to_long(n.post)
s_to_long(n.replace)
end
local a = node.get_attribute(n, sattr)
if a then
n.char = a
node.unset_attribute(n, sattr)
end
end
end
local function myhyph(head, tail)
long_to_s(head, tail)
lang.hyphenate(head, tail)
s_to_long(head, tail)
end
luatexbase.add_to_callback("hyphenate",myhyph,"hyphenate with modified s")
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here



LuaTeX also allows you to manipulate the hyphenation pattern during a run, so you can also use (this is an automated version of David Carlisles choice (b)):



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local l = lang.new(tex.language)
l:patterns(l:patterns():gsub('s', 'Å¿'))
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here






share|improve this answer


















  • 1




    +1 thanks :-)..
    – David Carlisle
    Aug 6 at 17:44










  • I accept this answer as it seems a clever solution (even though, for other reasons, I stick to XeLaTeX)
    – Martin Mueller
    Aug 7 at 8:37














up vote
9
down vote



accepted










For LuaTeX here is an implementation of David Carlisles idea to create a hypenate callback. It works by replacing every Å¿ with a marked s before hyphenation and then recovering the original characters after hyphenation:



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local sattr = luatexbase.new_attribute("longsattr")
local disc = node.id'disc'
print('DISC', disc)

local function long_to_s(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
print(n)
long_to_s(n.pre)
long_to_s(n.post)
long_to_s(n.replace)
end
if n.char == 383 then
n.char = 115
node.set_attribute(n, sattr, 383)
end
end
end
local function s_to_long(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
s_to_long(n.pre)
s_to_long(n.post)
s_to_long(n.replace)
end
local a = node.get_attribute(n, sattr)
if a then
n.char = a
node.unset_attribute(n, sattr)
end
end
end
local function myhyph(head, tail)
long_to_s(head, tail)
lang.hyphenate(head, tail)
s_to_long(head, tail)
end
luatexbase.add_to_callback("hyphenate",myhyph,"hyphenate with modified s")
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here



LuaTeX also allows you to manipulate the hyphenation pattern during a run, so you can also use (this is an automated version of David Carlisles choice (b)):



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local l = lang.new(tex.language)
l:patterns(l:patterns():gsub('s', 'Å¿'))
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here






share|improve this answer


















  • 1




    +1 thanks :-)..
    – David Carlisle
    Aug 6 at 17:44










  • I accept this answer as it seems a clever solution (even though, for other reasons, I stick to XeLaTeX)
    – Martin Mueller
    Aug 7 at 8:37












up vote
9
down vote



accepted







up vote
9
down vote



accepted






For LuaTeX here is an implementation of David Carlisles idea to create a hypenate callback. It works by replacing every Å¿ with a marked s before hyphenation and then recovering the original characters after hyphenation:



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local sattr = luatexbase.new_attribute("longsattr")
local disc = node.id'disc'
print('DISC', disc)

local function long_to_s(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
print(n)
long_to_s(n.pre)
long_to_s(n.post)
long_to_s(n.replace)
end
if n.char == 383 then
n.char = 115
node.set_attribute(n, sattr, 383)
end
end
end
local function s_to_long(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
s_to_long(n.pre)
s_to_long(n.post)
s_to_long(n.replace)
end
local a = node.get_attribute(n, sattr)
if a then
n.char = a
node.unset_attribute(n, sattr)
end
end
end
local function myhyph(head, tail)
long_to_s(head, tail)
lang.hyphenate(head, tail)
s_to_long(head, tail)
end
luatexbase.add_to_callback("hyphenate",myhyph,"hyphenate with modified s")
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here



LuaTeX also allows you to manipulate the hyphenation pattern during a run, so you can also use (this is an automated version of David Carlisles choice (b)):



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local l = lang.new(tex.language)
l:patterns(l:patterns():gsub('s', 'Å¿'))
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here






share|improve this answer














For LuaTeX here is an implementation of David Carlisles idea to create a hypenate callback. It works by replacing every Å¿ with a marked s before hyphenation and then recovering the original characters after hyphenation:



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local sattr = luatexbase.new_attribute("longsattr")
local disc = node.id'disc'
print('DISC', disc)

local function long_to_s(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
print(n)
long_to_s(n.pre)
long_to_s(n.post)
long_to_s(n.replace)
end
if n.char == 383 then
n.char = 115
node.set_attribute(n, sattr, 383)
end
end
end
local function s_to_long(head, tail)
for n in node.traverse(head) do
if n == tail then break end
if n.id == disc then
s_to_long(n.pre)
s_to_long(n.post)
s_to_long(n.replace)
end
local a = node.get_attribute(n, sattr)
if a then
n.char = a
node.unset_attribute(n, sattr)
end
end
end
local function myhyph(head, tail)
long_to_s(head, tail)
lang.hyphenate(head, tail)
s_to_long(head, tail)
end
luatexbase.add_to_callback("hyphenate",myhyph,"hyphenate with modified s")
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here



LuaTeX also allows you to manipulate the hyphenation pattern during a run, so you can also use (this is an automated version of David Carlisles choice (b)):



documentclassarticle
usepackage[ngerman]babel
usepackageluacode
beginluacode*
local l = lang.new(tex.language)
l:patterns(l:patterns():gsub('s', 'Å¿'))
endluacode*
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

XXX Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft Geſellſchaft
enddocument


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 7 at 6:48

























answered Aug 6 at 17:32









Marcel Krüger

9,7561828




9,7561828







  • 1




    +1 thanks :-)..
    – David Carlisle
    Aug 6 at 17:44










  • I accept this answer as it seems a clever solution (even though, for other reasons, I stick to XeLaTeX)
    – Martin Mueller
    Aug 7 at 8:37












  • 1




    +1 thanks :-)..
    – David Carlisle
    Aug 6 at 17:44










  • I accept this answer as it seems a clever solution (even though, for other reasons, I stick to XeLaTeX)
    – Martin Mueller
    Aug 7 at 8:37







1




1




+1 thanks :-)..
– David Carlisle
Aug 6 at 17:44




+1 thanks :-)..
– David Carlisle
Aug 6 at 17:44












I accept this answer as it seems a clever solution (even though, for other reasons, I stick to XeLaTeX)
– Martin Mueller
Aug 7 at 8:37




I accept this answer as it seems a clever solution (even though, for other reasons, I stick to XeLaTeX)
– Martin Mueller
Aug 7 at 8:37










up vote
2
down vote













A simple way to do this is to choose a font that supports Å¿ as an open type character variant, e.g., EB Garamond. Then you can just select that variant when you need it.



(Re-reading the comments above, I see this corresponds to option (c) from David Carlisle, which you said wasn't suitable, but this MWE shows you can have both kinds of s with this method.)



Update showing iſt and ſelbes.



documentclassarticle
usepackage[ngerman]babel
babelfontrmEB Garamond
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

addfontfeatureCharacterVariant=1

XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

ist selbes
enddocument


enter image description here






share|improve this answer






















  • You're right about the font. Though dis is not exactly David Carlisles option c and is no proper way to do it, because though all Å¿ are s, not all s are Å¿. The rule is, i think, that at the beginning of a word and in between letters it's an Å¿ – if not a long vocal is right before it. So it's »iÅ¿t« and »Å¿elbes«.
    – Martin Mueller
    Aug 7 at 8:36










  • @MartinMueller, EB Garamond does not change it at the end of a word, but I think it changes it everywhere else. I'm not a German speaker though, so I do not know what it should be.
    – David Purton
    Aug 7 at 8:44










  • Thank you for pointing that out. I've installed the EB Garamond but unfortunately the rules of Å¿ are far more complex than I knew (see wikipedia) and using your method does not produce the desired result. E.g. lesbisch should be lesbiÅ¿ch but is rendered leÅ¿biÅ¿ch
    – Martin Mueller
    Aug 7 at 12:20










  • @MartinMueller, that's a pity! The EB Garamond manual does warn that this feature isn't all that clever.
    – David Purton
    Aug 7 at 12:30















up vote
2
down vote













A simple way to do this is to choose a font that supports Å¿ as an open type character variant, e.g., EB Garamond. Then you can just select that variant when you need it.



(Re-reading the comments above, I see this corresponds to option (c) from David Carlisle, which you said wasn't suitable, but this MWE shows you can have both kinds of s with this method.)



Update showing iſt and ſelbes.



documentclassarticle
usepackage[ngerman]babel
babelfontrmEB Garamond
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

addfontfeatureCharacterVariant=1

XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

ist selbes
enddocument


enter image description here






share|improve this answer






















  • You're right about the font. Though dis is not exactly David Carlisles option c and is no proper way to do it, because though all Å¿ are s, not all s are Å¿. The rule is, i think, that at the beginning of a word and in between letters it's an Å¿ – if not a long vocal is right before it. So it's »iÅ¿t« and »Å¿elbes«.
    – Martin Mueller
    Aug 7 at 8:36










  • @MartinMueller, EB Garamond does not change it at the end of a word, but I think it changes it everywhere else. I'm not a German speaker though, so I do not know what it should be.
    – David Purton
    Aug 7 at 8:44










  • Thank you for pointing that out. I've installed the EB Garamond but unfortunately the rules of Å¿ are far more complex than I knew (see wikipedia) and using your method does not produce the desired result. E.g. lesbisch should be lesbiÅ¿ch but is rendered leÅ¿biÅ¿ch
    – Martin Mueller
    Aug 7 at 12:20










  • @MartinMueller, that's a pity! The EB Garamond manual does warn that this feature isn't all that clever.
    – David Purton
    Aug 7 at 12:30













up vote
2
down vote










up vote
2
down vote









A simple way to do this is to choose a font that supports Å¿ as an open type character variant, e.g., EB Garamond. Then you can just select that variant when you need it.



(Re-reading the comments above, I see this corresponds to option (c) from David Carlisle, which you said wasn't suitable, but this MWE shows you can have both kinds of s with this method.)



Update showing iſt and ſelbes.



documentclassarticle
usepackage[ngerman]babel
babelfontrmEB Garamond
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

addfontfeatureCharacterVariant=1

XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

ist selbes
enddocument


enter image description here






share|improve this answer














A simple way to do this is to choose a font that supports Å¿ as an open type character variant, e.g., EB Garamond. Then you can just select that variant when you need it.



(Re-reading the comments above, I see this corresponds to option (c) from David Carlisle, which you said wasn't suitable, but this MWE shows you can have both kinds of s with this method.)



Update showing iſt and ſelbes.



documentclassarticle
usepackage[ngerman]babel
babelfontrmEB Garamond
begindocument
XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

addfontfeatureCharacterVariant=1

XXX Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft Gesellschaft

ist selbes
enddocument


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 7 at 10:13

























answered Aug 7 at 5:45









David Purton

6,1701529




6,1701529











  • You're right about the font. Though dis is not exactly David Carlisles option c and is no proper way to do it, because though all Å¿ are s, not all s are Å¿. The rule is, i think, that at the beginning of a word and in between letters it's an Å¿ – if not a long vocal is right before it. So it's »iÅ¿t« and »Å¿elbes«.
    – Martin Mueller
    Aug 7 at 8:36










  • @MartinMueller, EB Garamond does not change it at the end of a word, but I think it changes it everywhere else. I'm not a German speaker though, so I do not know what it should be.
    – David Purton
    Aug 7 at 8:44










  • Thank you for pointing that out. I've installed the EB Garamond but unfortunately the rules of Å¿ are far more complex than I knew (see wikipedia) and using your method does not produce the desired result. E.g. lesbisch should be lesbiÅ¿ch but is rendered leÅ¿biÅ¿ch
    – Martin Mueller
    Aug 7 at 12:20










  • @MartinMueller, that's a pity! The EB Garamond manual does warn that this feature isn't all that clever.
    – David Purton
    Aug 7 at 12:30

















  • You're right about the font. Though dis is not exactly David Carlisles option c and is no proper way to do it, because though all Å¿ are s, not all s are Å¿. The rule is, i think, that at the beginning of a word and in between letters it's an Å¿ – if not a long vocal is right before it. So it's »iÅ¿t« and »Å¿elbes«.
    – Martin Mueller
    Aug 7 at 8:36










  • @MartinMueller, EB Garamond does not change it at the end of a word, but I think it changes it everywhere else. I'm not a German speaker though, so I do not know what it should be.
    – David Purton
    Aug 7 at 8:44










  • Thank you for pointing that out. I've installed the EB Garamond but unfortunately the rules of Å¿ are far more complex than I knew (see wikipedia) and using your method does not produce the desired result. E.g. lesbisch should be lesbiÅ¿ch but is rendered leÅ¿biÅ¿ch
    – Martin Mueller
    Aug 7 at 12:20










  • @MartinMueller, that's a pity! The EB Garamond manual does warn that this feature isn't all that clever.
    – David Purton
    Aug 7 at 12:30
















You're right about the font. Though dis is not exactly David Carlisles option c and is no proper way to do it, because though all Å¿ are s, not all s are Å¿. The rule is, i think, that at the beginning of a word and in between letters it's an Å¿ – if not a long vocal is right before it. So it's »iÅ¿t« and »Å¿elbes«.
– Martin Mueller
Aug 7 at 8:36




You're right about the font. Though dis is not exactly David Carlisles option c and is no proper way to do it, because though all Å¿ are s, not all s are Å¿. The rule is, i think, that at the beginning of a word and in between letters it's an Å¿ – if not a long vocal is right before it. So it's »iÅ¿t« and »Å¿elbes«.
– Martin Mueller
Aug 7 at 8:36












@MartinMueller, EB Garamond does not change it at the end of a word, but I think it changes it everywhere else. I'm not a German speaker though, so I do not know what it should be.
– David Purton
Aug 7 at 8:44




@MartinMueller, EB Garamond does not change it at the end of a word, but I think it changes it everywhere else. I'm not a German speaker though, so I do not know what it should be.
– David Purton
Aug 7 at 8:44












Thank you for pointing that out. I've installed the EB Garamond but unfortunately the rules of ſ are far more complex than I knew (see wikipedia) and using your method does not produce the desired result. E.g. lesbisch should be lesbiſch but is rendered leſbiſch
– Martin Mueller
Aug 7 at 12:20




Thank you for pointing that out. I've installed the EB Garamond but unfortunately the rules of ſ are far more complex than I knew (see wikipedia) and using your method does not produce the desired result. E.g. lesbisch should be lesbiſch but is rendered leſbiſch
– Martin Mueller
Aug 7 at 12:20












@MartinMueller, that's a pity! The EB Garamond manual does warn that this feature isn't all that clever.
– David Purton
Aug 7 at 12:30





@MartinMueller, that's a pity! The EB Garamond manual does warn that this feature isn't all that clever.
– David Purton
Aug 7 at 12:30













 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f444847%2f%25c5%25bf-long-s-and-hyphenation%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

Installing NextGIS Connect into QGIS 3?

One-line joke