I'm still on my way to my key:value table, and this time, I'm trying to alias [\normalbaselineskip] to \\. I still want to use the standard \\. What I want is to consider \\ as [\normalbaselineskip] only if it follows directly (without space) another \\. Typically, if I type \\\\ in the tabularx environment below, the first needs to be interpreted as a standard \\ and the second as [\normalbaselineskip]. Where things goes tricky is that I want, if possible, to restrict the scope of that \\\\ alias only to this tabularx (keyvalue) environment.

{\tabularx{\textwidth}{X@{ : }X}}
    Foo bar lorem ipsum           & Lorem ipusm que \\
    Some number                   & 12 3456 789  8  \\
    \multicolumn{2}{l}{This is some comment}        \\[\normalbaselineskip]
    Yet some number               & 987 65432 1     \\
    Foo bar                       & 163883495778    \\[\normalbaselineskip]
    Bar lorem ipsum               & 2013-04-12      \\

Thanks in advance for your help.

  • The main intent here is to avoid the printing of :, correct? – Werner Feb 9 '15 at 0:09
  • Sounds confusing to me. Why not just use a macro? That's what they're for, after all. Something like \newcommand{\wget}{\\[\normalbaselineskip]}.... – jon Feb 9 '15 at 0:09
  • \newcommand{\wgetbreak}{\addlinespace[\normalbaselineskip]} and add \wgetbreak after \\ where you want more space. – egreg Feb 9 '15 at 0:14
  • @Werner This isn't the subject of this question, but yes, one of the intend of ` \multicolumn{2}{l}{This is some comment}` is to avoid the colon : to be printed when there is only one element in the row. – wget Feb 9 '15 at 7:50
  • 1
    a command may consist only of one escape character (ordinarily \\) and either (a) any number of letters, or (b) only one non-letter. since you can't redefine \ to be a letter, trying to redefine \\\\ is simply impossible. – barbara beeton Feb 9 '15 at 13:21

As mentioned in the comments to the question, defining a new command as \\\\ is impossible, because redefining \ conflicts with the existing meaning of \ used as an escape sequence.

Even if \\\\ seems to be more convenient to type instead of \\[\normalbaselineskip], this is not a good coding practise (loss of readability). Use cases like adding more backslashes should have been handled with care too, increasing the risk to have an infinite loop, like I experienced.

A compromise I made was to use a macro, like proposed, but a shorter one: \x.

Here is the new definition of the keyvalue environnement I have:

    \begin{longtabu} to \textwidth {X@{ : }X}%

Yes, in the meantime, I migrated from tabularx to tabu allowing long tables (like the package longtable, but with way more features to it).

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.