2

Update, much later

Don’t do this. Change the font instead. This just causes much trouble in unexpected and hard-to-debug places. See the other answer to the same question for details.

changing the direction of the slash of the digit zero

In this answer I learned how to change the direction of the slash through the digit 0 inside a texttt block. This works fine, except it doesn’t work in a ticket environment.

Note we use pdflatex (run twice).

business cards

SSCCE:

\documentclass[a4paper,11pt]{article}
\usepackage[zw32010,boxed]{ticket}% for debugging
\RequirePackage[utf8]{inputenc}
\RequirePackage[pdftex]{graphics}
\RequirePackage{ngerman}
\RequirePackage[ngerman]{babel}
\RequirePackage[T1]{fontenc}
\RequirePackage{pxfonts}
\renewcommand{\familydefault}{\sfdefault}

\newcommand\0{\scalebox{-1}[1]{0}}
\let\svttfamily\ttfamily
\let\svtexttt\texttt
\catcode`0=\active
\def0{\0}
\renewcommand\ttfamily{\svttfamily\catcode`0=\active }
\renewcommand\texttt{\bgroup\ttfamily\texttthelp}
\def\texttthelp#1{#1\egroup}
\catcode`0=12

\renewcommand{\ticketdefault}{
    \put(1,46){\LARGE SSCCE}
    \put(2,38){texttt:}
    \put(2,32){implicit:}
    \put(2,26){explicit:}
}

\newcommand{\vcard}[1]{\ticket{
    \put(30,38){\texttt{#1}}
    \put(30,32){\ttfamily #1}
    \put(30,26){\ttfamily\catcode`0=\active #1}
}}

\begin{document}

\vcard{x0y}

\vspace{10cm}

Outside, \texttt{a0b} with texttt.

\end{document}

As you can see, the slash through the 0 is from bottom-left to top-right outside, but I can’t seem to get it working for inside the business card. I thought this was because of \put at first, but placing the text of the \ticketdefault or \ticket in there “raw”, i.e. not inside a \put, doesn’t fix it either:

\newcommand{\vcard}[1]{\ticket{

        Outside \texttt{m0n} with texttt.

        \put(30,38){\texttt{#1}}
        \put(30,32){\ttfamily #1}
        \put(30,26){\ttfamily\catcode`0=\active #1}
}}

(same for \ticketdefault)

tables

\RequirePackage[utf8]{inputenc}
\RequirePackage[pdftex]{graphics}
\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp}
\RequirePackage{graphicx}
\RequirePackage{pxfonts}
\renewcommand{\familydefault}{\sfdefault}
\RequirePackage{hyphenat}

\documentclass{scrartcl}

\newcommand\0{\scalebox{-1}[1]{0}}
\let\svttfamily\ttfamily
\let\svtexttt\texttt
\catcode`0=\active
\def0{\0}
\renewcommand\ttfamily{\svttfamily\catcode`0=\active }
\renewcommand\texttt{\bgroup\ttfamily\texttthelp}
\def\texttthelp#1{#1\egroup}
\catcode`0=12

\usepackage{tabu}
\usepackage{longtable}

\usepackage[export]{adjustbox}

\begin{document}

Das kann doch nicht sein! foo0bar \texttt{baz0blah} meh!

 \begin{longtabu} to \linewidth {|@{}c@{}|X|X|l|l|l|l|}
\hline\rowfont\bfseries Foto & Nachname & Vorname & Geburts\-datum & Benutzer & Fahrt & Fahr\-karte \\\hline
\endhead
x & \nohyphens{Lastname} & \nohyphens{Firstname} & \nohyphens{1970-01-01} & \texttt{hal2001} & \nohyphens{nein} & \nohyphens{nein}\\\hline
 \end{longtabu}
\end{document}

As can be seen, this also does not work in tables ☹

1

You have to activate 0 before absorbing the argument; I also present a fixed version of the reversed slashed zero macros.

\documentclass[a4paper,11pt]{article}
\usepackage[zw32010,boxed]{ticket}% for debugging
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{graphicx}
\usepackage{letltxmacro}
\usepackage{pxfonts}

\renewcommand{\familydefault}{\sfdefault}

\LetLtxMacro\svttfamily\ttfamily
\begingroup\ttfamily\endgroup
\DeclareRobustCommand\ttfamily{%
  \catcode`0=\active
  \svttfamily
}
\LetLtxMacro{\svtexttt}{\texttt}
\DeclareRobustCommand{\texttt}{\begingroup\catcode`0=\active\dotexttt}
\newcommand\dotexttt[1]{\svtexttt{#1}\endgroup}

\newcommand\0{\scalebox{-1}[1]{0}}

\begingroup\lccode`~=`0 \lowercase{\endgroup\def~}{\0}

\renewcommand{\ticketdefault}{%
  \put(1,46){\LARGE SSCCE}%
  \put(2,38){texttt:}%
  \put(2,32){implicit:}%
  \put(2,26){explicit:}%
}

\newcommand{\vcard}{\begingroup\catcode`0=\active\dovcard}
\newcommand{\dovcard}[1]{%
  \ticket{%
    \put(30,38){\texttt{#1}}%
    \put(30,32){\ttfamily#1}%
    \put(30,26){\ttfamily#1}%
  }%
  \endgroup
}

\begin{document}

Outside, \texttt{a0b} with texttt. 

\vcard{x0y}

\end{document}

enter image description here

A different implementation with expl3 that doesn't require a helper command for \vcard, avoiding a group.

\documentclass[a4paper,11pt]{article}
\usepackage[zw32010,boxed]{ticket}% for debugging
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}

\usepackage{graphicx}
\usepackage{letltxmacro,xparse}
\usepackage{pxfonts}

\renewcommand{\familydefault}{\sfdefault}

\newcommand\0{\scalebox{-1}[1]{0}}

% save the meaning of \ttfamily
\LetLtxMacro\svttfamily\ttfamily
% load the .fd file before changing the meaning of \ttfamily
\begingroup\ttfamily\endgroup

\ExplSyntaxOn
\RenewDocumentCommand{\ttfamily}{}
 {
  \char_set_catcode_active:N 0
  \svttfamily
 }
\RenewDocumentCommand{\texttt}{m}
 {
  \group_begin:
  \ttfamily
  \tl_rescan:nn { } { #1 }
  \group_end:
 }
\ExplSyntaxOff

\begingroup\lccode`~=`0 \lowercase{\endgroup\def~}{\0}

\renewcommand{\ticketdefault}{%
  \put(1,46){\LARGE SSCCE}%
  \put(2,38){texttt:}%
  \put(2,32){implicit:}%
  \put(2,26){explicit:}%
}

\newcommand{\vcard}[1]{%
  \ticket{%
    \put(30,38){\texttt{#1}}%
    \put(30,32){\ttfamily#1}%
    \put(30,26){\ttfamily#1}%
  }%
}

\begin{document}

Outside, \texttt{a0b} with texttt.

Outside, {\ttfamily a0b} with ttfamily.

\vcard{x0y}

\end{document}

enter image description here

  • @mirabilos I hope it is good now. – egreg Aug 24 '15 at 21:34
  • What does \begingroup\lccode~=0 \lowercase{\endgroup\def~}{\0} do? – mirabilos Aug 24 '15 at 22:04
  • @mirabilos It defines the active version of 0, avoiding resetting the category code. See tex.stackexchange.com/questions/156759/the-lowercase-trick – egreg Aug 24 '15 at 22:05
  • OK, thanks. I do not even pretend to understand that, less than the previous version, even if I can see a few things… so, on to tables: any idea wrt. them? This works for normal text, lstlistings, and business cards now, so far. – mirabilos Aug 24 '15 at 22:13
  • 1
    @mirabilos My choice would be forgetting a font that doesn't satisfy your needs. There are many things that can go wrong with an active 0; for example, {\ttfamily\setlength{\mylength}{10pt}...} will break horribly. – egreg Aug 24 '15 at 22:18

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.