4

I want to disable hyphenation in footnotes, because I have special codes for a special program and the readers should copy this code into his program and therefore its not good, that there is a hyphen ("-") inside the code. See my example in the third line.

\documentclass[a4paper,12pt]{scrartcl} 
\usepackage[T1]{fontenc}
\usepackage[ngerman, frenchb]{babel}
\frenchbsetup{StandardLayout=true}
\usepackage[automark]{scrpage2}
\deffootnote{1em}{1em}{\textsuperscript{\thefootnotemark\ }}

\usepackage[automark]{scrpage2}


\begin{document}
This is a test\footnote{\#vfini :[cat="Snt" \& type="VFin"] \& \#vfini >L \#v :[ ] \& \#before\_v :[ ] .* \#v \& \#cat3 :[cat!=/(Rfc|Apst|Ng)/] >* \#before\_v \& \#cat3 >@l \#cat3\_init :[ ] \& \#before\_cat3\_init :[ ] . \#cat3\_init \& \#cat2 :[cat ="Circ"] >* \#before\_cat3\_init \& \#cat2 >@l \#cat2\_init :[ ] \& \#before\_cat2\_init :[ ] . \#cat2\_init \& \#cat1 :[cat!=/(RelNC|Apst|Ng|Circ)/] >* \#before\_cat2\_init \& \#vfini > \#cat1 \& \#vfini > \#cat2 \& \#vfini > \#cat3 \& \#cat1 >@l \#cat1\_init :[ ] \& \#vfini >@l \#cat1\_init}

\end{document}
Marco Daniel
  • 95,681
  • 3
    You could just use \raggedright. As in, \footnote{\raggedright ...}. Since this is code though, I would use some fixed-width font as well. – Werner Apr 29 '13 at 19:15
  • 4
    Use \def\nohyph{\hyphenpenalty=10000\relax\exhyphenpenalty=10000\relax} \addtokomafont{footnote}{\nohyph} – Marco Daniel Apr 29 '13 at 19:16

2 Answers2

5

To disable hyphens you can use \raggedright, \raggedleft or \centering. However you will loose your justification. To get a hyphenless justification you can change the relevant penalties \hyphenpenalty and \exhyphenpenalty. An explanation of defined penalties can be found: What are penalties and which ones are defined?

To simplify the call you can define the following macro:

\newcommand\nohyph{\hyphenpenalty=10000\relax\exhyphenpenalty=10000\relax} 

This macro can be used everywhere. To set the behaviour local you can call:

\footnote{\nohyph <here your text>}

KOMA allows a global modification of the font inside footnotes. You can simply add the defined macro to the definition by:

\addtokomafont{footnote}{\nohyph}

to set the macro \nohyph global.

related to your example I got the following output:

enter image description here

Marco Daniel
  • 95,681
2

This looks more like verbatim code than text. I’d use the \url macro from the url package with the obeyspaces option here.
Advantage: You don’t need to escape &, # or _.

Maybe a attachfile solution would be better to provide readers with code?

Code (url)

\documentclass[a4paper,12pt]{scrartcl} 
\usepackage[obeyspaces]{url}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\deffootnote{1em}{1em}{\textsuperscript{\thefootnotemark\ }}
\urlstyle{same}% comment out to get tt font.
\begin{document}
This is a test\footnote{%
\url{#vfini :[cat="Snt" & type="VFin"] & #vfini >L #v :[ ] & #before_v :[ ] .* #v & #cat3 :[cat!=/(Rfc|Apst|Ng)/] >* #before_v & #cat3 >@l #cat3_init :[ ] & #before_cat3_init :[ ] . #cat3_init & #cat2 :[cat ="Circ"] >* #before_cat3_init & #cat2 >@l #cat2_init :[ ] & #before_cat2_init :[ ] . #cat2_init & #cat1 :[cat!=/(RelNC|Apst|Ng|Circ)/] >* #before_cat2_init & #vfini > #cat1 & #vfini > #cat2 & #vfini > #cat3 & #cat1 >@l #cat1_init :[ ] & #vfini >@l #cat1_init}}
\end{document}

Output

enter image description here

Code (attachfile)

\documentclass[a4paper,12pt]{scrartcl} 
\begin{filecontents}{code1.txt}
#vfini :[cat="Snt" & type="VFin"] & #vfini >L #v :[ ] & #before_v :[ ] .* #v & #cat3 :[cat!=/(Rfc|Apst|Ng)/] >* #before_v & #cat3 >@l #cat3_init :[ ] & #before_cat3_init :[ ] . #cat3_init & #cat2 :[cat ="Circ"] >* #before_cat3_init & #cat2 >@l #cat2_init :[ ] & #before_cat2_init :[ ] . #cat2_init & #cat1 :[cat!=/(RelNC|Apst|Ng|Circ)/] >* #before_cat2_init & #vfini > #cat1 & #vfini > #cat2 & #vfini > #cat3 & #cat1 >@l #cat1_init :[ ] & #vfini >@l #cat1_init
\end{filecontents}
\usepackage{attachfile}
\attachfilesetup{color=.5 0 .5}
\hypersetup{hidelinks}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\deffootnote{1em}{1em}{\textsuperscript{\thefootnotemark\ }}
\begin{document}
This is a test\footnote{See \textattachfile{code1.txt}{code sampe 1}.}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821