I recommend to define a style for acronyms. This allows consistent style changes later, for example if you change the typographic design of acronyms (such as using small caps) or introducing index commands.
And in this macro it's easy to prevent hyphenation, such as with \mbox
.
\newcommand{\Acronym}[1]{\mbox{\textsc{#1}}}
Some typographers recommend to space out all-caps words a bit. That's what \textsc
does here for you.
\documentclass{article}
\usepackage[english]{babel}
\newcommand{\Acronym}[1]{\mbox{\textsc{#1}}}
\begin{document}
\parbox{5em}{An EXAMPLE}
\quad
\parbox{5em}{An \Acronym{EXAMPLE}}
\end{document}
As far as I can see, you problem is not that hyphenation and hyphenation pattern in general do not work properly. Your overall problem is that words containing hyphens cannot be hyphenated elsewhere (see e.g. Adequate hyphenation of words already containing a hyphen) and specifically your problem is that the babel-german
solution "=
does not quite work with biblatex
(as also documented in your earlier question babelshorthand "= does not work with BibLaTeX?).
It might be instructive to briefly discuss why "=
does not work. "=
relies on "
being a shorthand/an active character and thus ultimately on category codes. At least for me, catcodes are one of the more tricky aspects of TeX programming. Essentially (but quite possibly not entirely correctly) TeX remembers the category code of each character it encounters. That category code is essentially frozen and cannot be changed after it has been read. So the category code settings at the point when code is "read" is relevant for how it behaves later on even if the category code of the characters involved are later changed.
biblatex
reads the contents of your bibliography items from the .bbl
file at \begin{document}
. This is done so that all data is available throughout the whole document. Crucially the file is read before babel
selects the document language. In particular even if your document language is ngerman
, where "
is an active character/shorthand, the .bbl
file is read at a time when "
is still a normal character and not at all a shorthand.
In fact "=
works fine if we already make "
a shorthand before \begin{document}
, because then "
is an active character when the .bbl
file is read (I cannot tell you if has any bad side-effects later on)
\documentclass[english,ngerman]{scrartcl}
\usepackage[style=numeric]{biblatex}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{dtk-logos}
\begin{filecontents}{\jobname.bib}
@Manual{class:scrguide,
title = {KOMA-Script},
author = {Kohm, Markus},
month = May,
year = 2016,
url = {http://www.komascript.de/~mkohm/scrguide.pdf},
langid = {ngerman},
note = {Bestandteil der Online"=Dokumentation von
\TeXLive, Datei \url{scrguide.pdf}},
keywords = {manual},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\shorthandon{"}
\begin{document}
Der Eintrag~\cite{class:scrguide} aus meiner
Literatur"=Datenbank erscheint im Quellen"=Verzeichnis leider mit
einem \verb|"=| in der Ausgabe.
\printbibliography
\end{document}
As Ulrike Fischer pointed out in the comments, biblatex
provides the command \hyphen
as a replacement for "=
that does not rely on (non-standard) category codes and thus works out of the box with all language settings.
\documentclass[english,ngerman]{scrartcl}
\usepackage[style=numeric]{biblatex}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{dtk-logos}
\begin{filecontents}{\jobname.bib}
@Manual{class:scrguide,
title = {KOMA-Script},
author = {Kohm, Markus},
month = May,
year = 2016,
url = {http://www.komascript.de/~mkohm/scrguide.pdf},
langid = {ngerman},
note = {Bestandteil der Online\hyphen Dokumentation von
\TeXLive, Datei \url{scrguide.pdf}},
keywords = {manual},
}
@Book{voss21:wissenschaftliche-arbeit-mit-latex,
author = {Voss, Herbert},
title = {Die wissenschaftliche Arbeit mit \LaTeX},
indextitle = {Wissenschaftliche Arbeit mit LaTeX, die},
year = 2021,
month = 6,
subtitle = {unter Verwendung von \LuaTeX{}, KOMA\hyphen Script und
Biber/\BibLaTeX{} und anderem mehr mehr},
series = {DANTE\hyphen Edition},
langid = {ngerman},
location = {Berlin},
keywords = {book},
pagetotal = 448,
edition = 2,
isbn = {978-3-96543-217-8},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Der Eintrag~\cite{class:scrguide,voss21:wissenschaftliche-arbeit-mit-latex} aus meiner
Literatur"=Datenbank erscheint im Quellen"=Verzeichnis leider mit
einem \verb|"=| in der Ausgabe.
\printbibliography
\end{document}
Note how "DANTE-Edition" is hyphenated correctly according to German rules even though it contains a hyphen.
If you prefer typing "=
over \hyphen
, you may be able to post-process your file to replace all "=
s by \hyphen
s.
biblatex
's \hyphen
is defined as \nobreak-\nobreak\hskip\z@skip
and so pretty much ends up doing what David Carlisle suggested in the comments.
Corporate\hyphen Design
is essentially
Corporate-\hspace{0pt}Design
Best Answer
This is discussed in detail in the TeX FAQ. Summarising the information given there:
You can set
\hyphenpenalty
and\exhyphenpenalty
to 10000, which will stop hyphenation, but as TeX will still try to hyphenate this is not hugely efficient.As Joel says, you can use
\usepackage[none]{hyphenat}
to select a 'language' with no hyphenation at all. This works fine for a single language document, but not if you want to usebabel
orpolyglossia
for other language-specific effects.Setting
\righthyphenmin
and\lefthyphenmin
to very large values will prevent hyphenation as it tells TeX that it must have more characters in the word than are going to be available. The suggested value in the FAQ is 62.You can set
\hyphenchar\font=-1
, which will prevent hyphenation for the current font: this is probably not the best way for an entire document but is how it is done for thett
font shape in LaTeX.Now, of those (2) is probably the best choice. However, what you did not say is why you want no hyphenation. TeX hyphenates when it cannot find a good line break without it, so you get few hyphens in most cases. The risk with no hyphenation at all is that the output looks bad.