TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am getting spurious blank spaces inserted upon loading a dtltool db.

The MWE below produces links to all the image files named with a prefix the same as the .tex file:

enter image description here

But if I comment out the \DTLloaddb line (as indicated by the comments in the code), this produces:

enter image description here

Note that the indentation increases as the number of files being linked to increases. Even with zero matches (as is the case for the A.tex file), there is still an indentation.

I suspect that this is related to an earlier problem of mine where I was seeing a Spurious blank space when adding a member to a database within \foreach. I tried to use added an \unskip whenever I invoke \AddMemberToDB, but that does not help in this case.

Bonus Question:

  • This is not really TeX related, but how do I change the invocation of ls such that the error messages such as the following are not displayed in the console.

    ls: B-*.pdf: No such file or directory

    I had this working with a discussion in the chat room, but started to break in my real use case.



%% -------------------------------------- Create the necessary files
%% Four .tex files:




% No .png file associated with A

% One image file associated with B

% Two image files associated with C

% Three image files associated with D
%% -------------------------------------- 

% http://tex.stackexchange.com/questions/51854/dtldeletedb-from-datatool-package-has-no-effect-within-foreach
%  Usage: Use \DTLgdeletedb instead of \DTLdeletedb
      \global\expandafter\let\csname dtl@ci@#1@\@dtl@key\endcsname\undefined
    \global\expandafter\let\csname dtldb@#1\endcsname\undefined
    \global\expandafter\let\csname dtlkeys@#1\endcsname\undefined
    \global\expandafter\let\csname dtlrows@#1\endcsname\undefined
    \global\expandafter\let\csname dtlcols@#1\endcsname\undefined
    \PackageError{***** Error: Can't delete database `#1':
       database doesn't exist}{}{}%

    %#1 = text color
    %#2 = file to open upon clicking
    %#3 = text to display

    % #1 = temp file name
    % #2 = dir        
    % #3 = file extension
        ls -1 #2#3 %
        | grep -v "No such file or directory" %
        | sort -f%
%       >&2 % List ALL files
        > ./#1% Store in given file name 


    \foreach \x in {A,...,D}{%
        % If comment out the following \DTLloaddb, the no additional indentation
                    % no associated image files found.
        % Add a new line if we are at the appropriate multiple
share|improve this question
I forgot to comment out an EOL character in \@dtl@readline. I'll get it fixed in the next version of datatool. – Nicola Talbot Dec 9 '12 at 14:17
This problem has been fixed in 2013/01/15 v2.13 version of datatool. – Peter Grill Jan 20 '13 at 5:43
up vote 3 down vote accepted

Here's a patch until the next version:

  \read#1 to #2%
  }% <- added comment character

(You can track the progress of the bug with my bug tracker.)

share|improve this answer
So, this is different than the problem discovered in Spurious blank space when adding a member to a database within \foreach. It seems that \let\Old@dtl@updatekeys\@dtl@updatekeys \renewcommand*{\@dtl@updatekeys}[3]{\Old@dtl@updatekeys{#1}{#2}{#3}\unskip} also works so thought that perhaps that was related. – Peter Grill Dec 10 '12 at 0:42
@PeterGrill It's a different problem but the same basic cause (a missing percent character at the end of a line). The problem with \@dtl@updatekeys was fixed in v2.11, so Werner's patch in your link is no longer required. (I tried neatening up the code in datatool.sty to make it easier to read, but I think I must've missed commenting some EOL characters. Hopefully that's the last one!) – Nicola Talbot Dec 10 '12 at 8:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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