3

I have the following table, where the IP addresses are supposed to be hyphenated after every ":". They can't have dashes though. Why does "" not split the word like it shoud with the babel package? In this minimal working example i included all packages i used in the original.

\documentclass[11pt,a4paper]{scrartcl}

% Pakete einbinden
\usepackage[english]{babel} % Englische Silbentrennung und Typografie 
\usepackage[T1]{fontenc} % Vektorschriften benutzen
\usepackage[utf8x]{inputenc} % Ermöglicht UTF-Sonderzeichen als Input 
\usepackage[colorlinks=false, pdfborder=0]{hyperref} % Hyperlinks
\usepackage{array}
\usepackage{longtable}
\usepackage{tabularx} 
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{ifthen} % Ermöglicht if-Anweisungen in Latex
\usepackage{colortbl} % Farbige Tabellen
\usepackage{ragged2e} % Für Tabellen
\usepackage{pdflscape} % Ermöglicht es bestimmte Seiten im Querformat anzuzeigen
\usepackage{eurosym} % Für das Eurozeichen
\usepackage{textcomp} % Für ordentliche Darstellung von Sonderzeichen
\usepackage{lmodern} % Ein hübscherer Font
\usepackage{courier} % Ein hübscherer Font für die Result-Zeilen in der Detailbeschreibung der Schwachstellen
\usepackage[a4paper,left=10mm,top=25mm,right=10mm,bottom=26mm]{geometry}


\begin{document}
\begin{longtable}[l]{p{.12\textwidth} p{.20\textwidth} p{.23\textwidth} p{.30\textwidth}}
\multicolumn{4}{>{\columncolor{blue}}l}{Part 2. Component Compliance Summary}\\


IP Address: &  192.168.1.100 & \cellcolor{red}FAIL & \\

IP Address: &  1234:""1234:""1234:""1234:"":""3b:""1 & \cellcolor{green}PASS & \\

IP Address: &  1234:\-1234:\-1234:\-1234:\-:\-1234:\-2 & \cellcolor{green}PASS & \\

IP Address: &  1234:\-1234:\-1234:\-1234:\-:\-5647:\-3 & \cellcolor{green}PASS & \\

IP Address: &  1234:\-1234:\-1234:\-1234:\-:\-5647:\-ce:\-25 & \cellcolor{green}PASS & \\
\end{longtable}
\end{document}

enter image description here

2
  • 1
    "" is a shorthand available in German babel but not in English, so it won't work in this document. I'd probably use hyperref's \nolinkurl for the job. (Note that hyperref should be loaded last.) I would also try to avoid \usepackage[utf8x]{inputenc}, usually \usepackage[utf8]{inputenc} should be enough (in April 2018 \usepackage[utf8]{inputenc} became the default, so if you use a current LaTeX version, you won't need the line at all.) KOMA classes like scrartcl and fancyhdr don't work together that well, you should consider scrlayer-scrpage instead.
    – moewe
    Sep 10, 2018 at 13:24
  • Thank you for the great tips. it works now. Do you know how to prevent the font from changing in \nolinkurl ?
    – Marius Rom
    Sep 10, 2018 at 13:34

1 Answer 1

3

The "" shorthand is not available in all babel languages. In particular it is available in all German dialects (ngerman etc.) but not for English dialects (english etc.). You can define a command that does the same as "" with

\makeatletter
\newcommand*{\nohyphenbreakpoint}{\hskip\z@skip}
\makeatother 

Since you are loading hyperref (which loads url) I would use a command similar to \nolinkurl. The URL breaking algorithm works just fine for IP addresses as well.

I personally quite like the typewriter font you'd get from \nolinkurl, but it is more semantic to define a dedicated command for IPs and when defining it you might as well change the display style.

\documentclass[11pt,a4paper]{scrartcl}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{longtable}
\usepackage[table]{xcolor}
\usepackage{lmodern}
\usepackage[a4paper,left=10mm,top=25mm,right=10mm,bottom=26mm]{geometry}
\usepackage{hyperref}

\DeclareUrlCommand\ip{\urlstyle{same}}

\newcommand*{\cellpassfail}[1]{%
  \ifnum0#1<1
    \cellcolor{red}FAIL%
  \else
    \cellcolor{green}PASS%
  \fi
}

\begin{document}
\begin{longtable}[l]{p{.12\textwidth} p{.20\textwidth} p{.23\textwidth} p{.30\textwidth}}
\multicolumn{4}{>{\columncolor{blue}}l}{Part 2. Component Compliance Summary}\\
IP Address: &  \ip{192.168.1.100}                   & \cellpassfail{0} & \\
IP Address: &  \ip{1234:1234:1234:1234::3b:1}       & \cellpassfail{1} & \\
IP Address: &  \ip{1234:1234:1234:1234::1234:2}     & \cellpassfail{1} & \\
IP Address: &  \ip{1234:1234:1234:1234::5647:3}     & \cellpassfail{1} & \\
IP Address: &  \ip{1234:1234:1234:1234::5647:ce:25} & \cellpassfail{1} &
\end{longtable}
\end{document}

The table from the MWE with nicely breaking IPs

0

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.