I have written a macro that uses the functions in xstring:

\IfSubStr{#1}{-12-}{\StrSubstitute{#1}{-12-}{-Dec-}}{} }

What this does is change a date from 2015-10-07 to 2015-Oct-07. It works great, sort of. Now when I print it in a tabularx:

\begin{tabularx}{19cm}{p{1.75cm}C{1.85cm}C{2cm}L{2.5cm}L{4cm}L{4cm}} \hline
  \textbf{Invoice \#} & \textbf{Date} & \textbf{Customer \#} & \textbf{P.O. \#}
   & \textbf{Description} & \textbf{Salesperson} \\ [0.5em]
  <%invnumber%> & \yyyymmmdd{<%invdate%>} & <%customernumber%> & <%ponumber%> 
  & <%shippingpoint%> & <%employee%> \\

I get a blank line before and after the line of data. If I take out \yyyymmmdd and just print <%invdate%> I do not get the blank lines. What would cause this?

closed as unclear what you're asking by Zarko, Stefan Pinnow, gernot, user31729, Mensch Feb 11 '17 at 14:11

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    You're probably using something else to insert the "correct date" instead of <%invdate%>, as (La)TeX considers % to represent a comment character. My guess is you have spurious spaces in your macro, causing the problem. See What is the use of percent signs (%) at the end of lines?. – Werner Oct 7 '15 at 18:31
  • Please tell us how the L and C column types a defined. (Are they just raggedright and centered versions of X If so, why do they have explicit widths?) Please also provide at least two valid non-header rows of input for the tabularx environment, so that we can test what's going on. – Mico Oct 7 '15 at 18:45
  • 1
    there is no possible way tabularx can do anything useful with this table, all the column widths are specified in advance, and the cells are (I would guess) small items not involving linebreaking. tabularx is all about adjusting the widths for linebreaking with a column. – David Carlisle Oct 7 '15 at 18:56

With a simpler solution for the date macro. However, I do not know how you get the data. The reason why I used only text:

\newcolumntype{L}[1]{p{#1}}% dummy
\newcolumntype{C}[1]{p{#1}}% dummy

      \or Jan\or Feb\or Mar\or Apr\or May\or Jun\or Jul%
      \or Aug\or Sep\or Oct\or Nov\or Dec\fi


    \begin{tabularx}{19cm}{p{1.75cm}C{1.85cm}C{2cm}L{2.5cm}L{4cm}L{4cm}} \hline
        \textbf{Invoice \#} & \textbf{Date} & \textbf{Customer \#} & \textbf{P.O. \#}
        & \textbf{Description} & \textbf{Salesperson} \\ [0.5em]
        foo & \yyyymmmdd{2015-07-07} & foo & bar 
        & foobar & foobaz \\


Not the answer you're looking for? Browse other questions tagged or ask your own question.