5

I use frequently combination of these two sings

  1. · (used for word division)
  2. | (used to show where endings join the word)

For example it frequently appears this combination ··| (·· main division + | ending).

In few exceptions I would need to put · and | closer. How to put those signs closer in exceptional situation?

\documentclass[8pt]{extbook}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
 % normal
 hug·sjóna··|maður

 %closer
 hug·sjóna··|maður
\end{document}
2
  • 3
    ·\hspace{-1pt}| ? Jan 15, 2016 at 12:32
  • Yes, thank you. I use \hspace{-0.06667em} now.
    – chejnik
    Jan 15, 2016 at 12:38

2 Answers 2

4

You almost certainly don't want a line break after a centered dot, so it makes sense using a penalty that can be later examined.

\documentclass[fontsize=8pt]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}

\newunicodechar{·}{\chejnikcdot}
\makeatletter
\newcommand{\chejnikcdot}{%
  \ifnum\lastpenalty=10042
    \kern-0.06667em\relax % dots should always be kerned
  \fi
  \textperiodcentered
  \@ifnextchar|{\kern\chejnikkern\relax}{\penalty10042 }%
}

\newcommand{\closeupdotbar}{%
  \renewcommand\chejnikkern{-0.06667em}%
}
\newcommand\chejnikkern{0pt} % default


\begin{document}

\begin{tabular}{ll}
No kerning & hug\textperiodcentered sjóna\textperiodcentered\textperiodcentered|maður \\
Kerning & hug·sjóna··|maður \\
Kerning plus & \closeupdotbar hug·sjóna··|maður
\end{tabular}

\end{document}

The \closeupdotbar changes (locally) the kerning between a centered period and the vertical bar. In normal text you can do

{\closeupdotbar hug·sjóna··|maður}

for the special cases. Other interfaces are possible.

The \chejnikdot macro looks back: if it sees a penalty item with value 10042, it means that a centered dot has been typeset, so the macro applies a kern. Then it typesets the centered dot and issues the penalty that, besides being a signal, prohibits line breaks at the spot.

enter image description here

0
5
\documentclass[fontsize=8pt]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar,etoolbox}

\newif\ifclosersigns
\newunicodechar{·}{\advancedcdot}
\makeatletter
\newcommand*\advancedcdot{\textperiodcentered
  \ifclosersigns\expandafter\@firstofone
  \else\expandafter\@gobble\fi{\@ifnextchar|{\hspace{-0.06667em}}{}}}
\makeatother

\begin{document}
 % normal
 hug·sjóna··|maður

\closersignstrue

 %closer
 hug·sjóna··|maður
\end{document}

Addition to remove space from ·· and ·| (not completely robust, but I think it's enough).

\documentclass[fontsize=8pt]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar,etoolbox}

\newunicodechar{·}{\advancedcdot}
\makeatletter
\newcommand*\advancedcdot{\textperiodcentered
  \@ifnextchar|{\hspace{-0.06667em}}{\checkifcdotnext}}
\newcommand*\checkifcdotnext[2]
  {\def\tmpa{·}\def\tmpb{#1#2}\ifx\tmpa\tmpb\hspace{-0.06667em}\fi#1#2}
\makeatother

\begin{document}

 %closer
 hug·sjóna··|maður

\end{document}

A bit more robust would be

\newcommand*\advancedcdot{\textperiodcentered
  \@ifnextchar|{\hspace{-0.06667em}}{\@ifnextchar^^c2{\checkifcdotnext}{}}}
\newcommand*\checkifcdotnext[2]
  {\def\tmpa{·}\def\tmpb{#1#2}\ifx\tmpa\tmpb\hspace{-0.06667em}\fi#1#2}
7
  • 1
    Of course if you want to define the spacing globally it's easier. But I'm not sure if you wanted the two behaviours in the same document (since you said “normal” and “closer”).
    – Manuel
    Jan 15, 2016 at 12:42
  • Just to be completely sure, in combination ··| it takes -0.06667em space between two middle dots + -0.06667em space between middle dot and | sign, right? * that is desired behaviour*
    – chejnik
    Jan 15, 2016 at 14:13
  • Yes, that's what this does.
    – Manuel
    Jan 15, 2016 at 18:08
  • I have decided to accept the Egreg's answer, because \advanceddot command have thrown an error later in code, precisely at \multirow{5}{*}{ýmis\allowbreak ·} part of code. I appreciate your answer as well, thank you very much.
    – chejnik
    Jan 17, 2016 at 8:14
  • With the last definition? The “a bit more robust would be” version.
    – Manuel
    Jan 17, 2016 at 8:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .