Index: /trunk/doc/manual/docbook2latex.xsl
===================================================================
--- /trunk/doc/manual/docbook2latex.xsl	(revision 76234)
+++ /trunk/doc/manual/docbook2latex.xsl	(revision 76235)
@@ -911,8 +911,34 @@
   <xsl:template match="//text()">
 
+    <!-- Do the translation of \ into \textbackslash{} in two steps, to avoid
+         running into replacing {} as well which would be very wrong. -->
     <xsl:variable name="subst1">
       <xsl:call-template name="str:subst">
         <xsl:with-param name="text" select="." />
         <xsl:with-param name="replace" select="'\'" />
+        <xsl:with-param name="with" select="'\textbackslash'" />
+        <xsl:with-param name="disable-output-escaping" select="no" />
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:variable name="subst2">
+      <xsl:call-template name="str:subst">
+        <xsl:with-param name="text" select="$subst1" />
+        <xsl:with-param name="replace" select="'{'" />
+        <xsl:with-param name="with" select="'\{'" />
+        <xsl:with-param name="disable-output-escaping" select="no" />
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:variable name="subst3">
+      <xsl:call-template name="str:subst">
+        <xsl:with-param name="text" select="$subst2" />
+        <xsl:with-param name="replace" select="'}'" />
+        <xsl:with-param name="with" select="'\}'" />
+        <xsl:with-param name="disable-output-escaping" select="no" />
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:variable name="subst4">
+      <xsl:call-template name="str:subst">
+        <xsl:with-param name="text" select="$subst3" />
+        <xsl:with-param name="replace" select="'\textbackslash'" />
         <xsl:with-param name="with" select="'\textbackslash{}'" />
         <xsl:with-param name="disable-output-escaping" select="no" />
@@ -929,7 +955,7 @@
                    or (name(..) = 'replaceable')    or (name(../..) = 'replaceable')
                      ">
-        <xsl:variable name="subst2">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="translate(normalize-space(concat('&#x7F;',$subst1,'&#x7F;')),'&#x7F;','')" />
+        <xsl:variable name="subst5">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="translate(normalize-space(concat('&#x7f;',$subst4,'&#x7f;')),'&#x7f;','')" />
             <xsl:with-param name="replace" select="'--'" />
             <xsl:with-param name="with" select="'-{}-'" />
@@ -937,7 +963,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst3">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst2" />
+        <xsl:variable name="subst6">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst5" />
             <xsl:with-param name="replace" select="'_'" />
             <xsl:with-param name="with" select="'\_'" />
@@ -945,7 +971,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst4">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst3" />
+        <xsl:variable name="subst7">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst6" />
             <xsl:with-param name="replace" select="'$'" />
             <xsl:with-param name="with" select="'\$'" />
@@ -953,7 +979,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst5">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst4" />
+        <xsl:variable name="subst8">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst7" />
             <xsl:with-param name="replace" select="'%'" />
             <xsl:with-param name="with" select="'\%'" />
@@ -961,7 +987,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst6">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst5" />
+        <xsl:variable name="subst9">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst8" />
             <xsl:with-param name="replace" select="'#'" />
             <xsl:with-param name="with" select="'\#'" />
@@ -969,15 +995,15 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst7">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst6" />
+        <xsl:variable name="subst10">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst9" />
             <xsl:with-param name="replace" select="'~'" />
-            <xsl:with-param name="with" select="'\textasciitilde '" />
-            <xsl:with-param name="disable-output-escaping" select="no" />
-          </xsl:call-template>
-        </xsl:variable>
-        <xsl:variable name="subst8">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst7" />
+            <xsl:with-param name="with" select="'\textasciitilde{}'" />
+            <xsl:with-param name="disable-output-escaping" select="no" />
+          </xsl:call-template>
+        </xsl:variable>
+        <xsl:variable name="subst11">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst10" />
             <xsl:with-param name="replace" select="'&amp;'" />
             <xsl:with-param name="with" select="'\&amp;'" />
@@ -987,7 +1013,7 @@
         <xsl:choose>
           <xsl:when test="parent::arg or parent::command">
-            <xsl:variable name="subst9">
+            <xsl:variable name="subst12">
               <xsl:call-template name="str:subst">
-                <xsl:with-param name="text" select="$subst8" />
+                <xsl:with-param name="text" select="$subst10" />
                 <xsl:with-param name="replace" select="' '" />
                 <xsl:with-param name="with" select="'~'" />
@@ -995,8 +1021,8 @@
               </xsl:call-template>
             </xsl:variable>
-            <xsl:value-of select="$subst9" />
+            <xsl:value-of select="$subst12" />
           </xsl:when>
           <xsl:otherwise>
-            <xsl:value-of select="$subst8" />
+            <xsl:value-of select="$subst11" />
           </xsl:otherwise>
         </xsl:choose>
@@ -1004,7 +1030,7 @@
 
       <xsl:when test="(name(..)='address') or (name(../..)='address')">
-        <xsl:variable name="subst2">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst1" />
+        <xsl:variable name="subst5">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst4" />
             <xsl:with-param name="replace" select="'&#x0a;'" />
             <xsl:with-param name="with" select="' \\'" />
@@ -1012,28 +1038,12 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:value-of select="$subst2" />
+        <xsl:value-of select="$subst5" />
       </xsl:when>
 
       <!-- <screen> and <programlisting>, which work with alltt environment. -->
       <xsl:otherwise>
-        <xsl:variable name="subst2">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst1" />
-            <xsl:with-param name="replace" select="'{'" />
-            <xsl:with-param name="with" select="'\{'" />
-            <xsl:with-param name="disable-output-escaping" select="no" />
-          </xsl:call-template>
-        </xsl:variable>
-        <xsl:variable name="subst3">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst2" />
-            <xsl:with-param name="replace" select="'}'" />
-            <xsl:with-param name="with" select="'\}'" />
-            <xsl:with-param name="disable-output-escaping" select="no" />
-          </xsl:call-template>
-        </xsl:variable>
-        <xsl:variable name="subst4">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst3" />
+        <xsl:variable name="subst5">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst4" />
             <xsl:with-param name="replace" select="'_'" />
             <xsl:with-param name="with" select="'\_'" />
@@ -1041,7 +1051,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst5">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst4" />
+        <xsl:variable name="subst6">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst5" />
             <xsl:with-param name="replace" select="'$'" />
             <xsl:with-param name="with" select="'\$'" />
@@ -1049,7 +1059,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst6">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst5" />
+        <xsl:variable name="subst7">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst6" />
             <xsl:with-param name="replace" select="'%'" />
             <xsl:with-param name="with" select="'\%'" />
@@ -1057,7 +1067,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst7">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst6" />
+        <xsl:variable name="subst8">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst7" />
             <xsl:with-param name="replace" select="'#'" />
             <xsl:with-param name="with" select="'\#'" />
@@ -1065,7 +1075,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst8">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst7" />
+        <xsl:variable name="subst9">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst8" />
             <xsl:with-param name="replace" select="'µ'" />
             <xsl:with-param name="with" select="'$\mu$'" />
@@ -1073,7 +1083,7 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:variable name="subst9">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst8" />
+        <xsl:variable name="subst10">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst9" />
             <xsl:with-param name="replace" select="'®'" />
             <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
@@ -1086,14 +1096,14 @@
              with pretty quotes by invoking sed a few times. Unfortunately there are
              no regular expressions in XSLT so there's no other way. -->
-        <xsl:variable name="subst10">
+        <xsl:variable name="subst11">
           <xsl:choose>
             <xsl:when test="(name(..)='screen') or (name(../..)='screen')
                          or (name(..)='programlisting') or (name(../..)='programlisting')
                            ">
-              <xsl:value-of select="$subst9" />
+              <xsl:value-of select="$subst10" />
             </xsl:when>
             <xsl:otherwise>
               <xsl:call-template name="str:subst">
-                <xsl:with-param name="text" select="$subst9" />
+                <xsl:with-param name="text" select="$subst10" />
                 <xsl:with-param name="replace" select="$quote" />
                 <xsl:with-param name="with" select="'\QUOTE{}'" />
@@ -1103,15 +1113,15 @@
           </xsl:choose>
         </xsl:variable>
-        <xsl:variable name="subst11">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst10" />
+        <xsl:variable name="subst12">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst11" />
             <xsl:with-param name="replace" select="'~'" />
-            <xsl:with-param name="with" select="'\textasciitilde '" />
-            <xsl:with-param name="disable-output-escaping" select="no" />
-          </xsl:call-template>
-        </xsl:variable>
-        <xsl:variable name="subst12">
-          <xsl:call-template name="str:subst">
-            <xsl:with-param name="text" select="$subst11" />
+            <xsl:with-param name="with" select="'\textasciitilde{}'" />
+            <xsl:with-param name="disable-output-escaping" select="no" />
+          </xsl:call-template>
+        </xsl:variable>
+        <xsl:variable name="subst13">
+          <xsl:call-template name="str:subst">
+            <xsl:with-param name="text" select="$subst12" />
             <xsl:with-param name="replace" select="'&amp;'" />
             <xsl:with-param name="with" select="'\&amp;'" />
@@ -1119,5 +1129,5 @@
           </xsl:call-template>
         </xsl:variable>
-        <xsl:value-of select="$subst12" />
+        <xsl:value-of select="$subst13" />
       </xsl:otherwise>
     </xsl:choose>
