How to align the last element on the right when using hfill?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I am making a wine list from a CSV file (see my first question here: How to import data from excel and format it as text in LaTeX?) and I need to align the prices on the right.
To do this, I used the datatool
package to fetch the informations from my spreadsheet, DTLforeach
to iterate what I wanted to do and hfill
to align my prices on the right. (see code after the picture)
As you can see on the picture, it worked very well for every line but the last one of each (subsub)section, which is slightly misaligned:
Here is my code:
documentclass[12pt]article
usepackage[utf8]inputenc
% Pour modifer les marges
usepackagegeometry
% Marges du document
geometryhmargin=1.5cm,vmargin=1.5cm
% To remove the heading of the table of contents ("Contents")
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother %%% WAS makeatotherx = ERROR %%%
% To make itemized lists
% This package provides user control over the layout of the three basic list environments: enumerate, itemize and description. It supersedes both enumerate and mdwlist (providing well-structured replacements for all their funtionality), and in addition provides functions to compute the layout of labels, and to âÂÂcloneâ the standard environments, to create new environments with counters of their own.
usepackageenumitem
% Datatool package to load external files (csv)
usepackagedatatool
%--------------------------%
titleCarte des Vins
authorB
datetoday
%--------------------------%
setcountersecnumdepth-2
begindocument
maketitle
tableofcontents
%--------------------------%
newpage
sectionBordeaux
% Load CSV database (here bordeaux.csv)
% and give it a label (here BOR)
DTLloaddbBORbordeaux.csv
subsectionRed
%%%%%%% CUT CODE %%%%%%%%%%%%%%%%%%%%%%%%%
newpage
subsubsectionSaint-Julien
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
beginitemize %%% ABSENT IN MY ORIGINAL CODE %%%
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
enditemize %%% ABSENT IN MY ORIGINAL CODE %%%
%%%%%%%%%%%%%%%
subsubsectionMargaux
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Margaux (R04)
%%%%%%%%%%%%%%%%% CUT CODE%%%%%%%
enddocument
How can I align all my prices on the right?
Excerpt of my CSV file:
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
horizontal-alignment formatting datatool
 |Â
show 10 more comments
up vote
3
down vote
favorite
I am making a wine list from a CSV file (see my first question here: How to import data from excel and format it as text in LaTeX?) and I need to align the prices on the right.
To do this, I used the datatool
package to fetch the informations from my spreadsheet, DTLforeach
to iterate what I wanted to do and hfill
to align my prices on the right. (see code after the picture)
As you can see on the picture, it worked very well for every line but the last one of each (subsub)section, which is slightly misaligned:
Here is my code:
documentclass[12pt]article
usepackage[utf8]inputenc
% Pour modifer les marges
usepackagegeometry
% Marges du document
geometryhmargin=1.5cm,vmargin=1.5cm
% To remove the heading of the table of contents ("Contents")
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother %%% WAS makeatotherx = ERROR %%%
% To make itemized lists
% This package provides user control over the layout of the three basic list environments: enumerate, itemize and description. It supersedes both enumerate and mdwlist (providing well-structured replacements for all their funtionality), and in addition provides functions to compute the layout of labels, and to âÂÂcloneâ the standard environments, to create new environments with counters of their own.
usepackageenumitem
% Datatool package to load external files (csv)
usepackagedatatool
%--------------------------%
titleCarte des Vins
authorB
datetoday
%--------------------------%
setcountersecnumdepth-2
begindocument
maketitle
tableofcontents
%--------------------------%
newpage
sectionBordeaux
% Load CSV database (here bordeaux.csv)
% and give it a label (here BOR)
DTLloaddbBORbordeaux.csv
subsectionRed
%%%%%%% CUT CODE %%%%%%%%%%%%%%%%%%%%%%%%%
newpage
subsubsectionSaint-Julien
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
beginitemize %%% ABSENT IN MY ORIGINAL CODE %%%
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
enditemize %%% ABSENT IN MY ORIGINAL CODE %%%
%%%%%%%%%%%%%%%
subsubsectionMargaux
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Margaux (R04)
%%%%%%%%%%%%%%%%% CUT CODE%%%%%%%
enddocument
How can I align all my prices on the right?
Excerpt of my CSV file:
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
horizontal-alignment formatting datatool
1
Unfortunately the code as shown can't be run (a good MWE for LaTeX should start withdocumentclass
and should have abegindocument...enddocument
pair, in this case it would also help if you could supply example.csv
data, see tex.meta.stackexchange.com/q/228/35864), so I can only guess that you are missing a%
somewhere.
â moewe
Sep 22 at 13:52
3
I did compile your document here... Have you noticed you are getting lots of compilation errors? You really shouldn't ignore these. Your code is doing anitem
without being wrapped in a list environment (and this is adding a space after the last entry). Try addingbeginitemize
before theDTLforeach
command and anenditemize
after it. The output should look right then. Ooh, and you have a typo. You havemakeatotherx
, with an extrax
.
â Phelype Oleinik
Sep 22 at 14:20
2
I get two kinds of errors: (1)! Undefined control sequence. l.28 makeatotherx
. It should have beenmakeatother
instead. (2)! LaTeX Error: Lonely item--perhaps a missing list environment.
. This is because you haveitem
in your code when there is noitemize
orenumerate
to make use of it. That causes an error.
â moewe
Sep 22 at 14:23
2
Yes, but errors must be fixed even if superficially they don't affect the PDF - the absolutely affect the output. TeX has a limited ability to recover from errors, but usually it has to guess what to do and that is rarely exactly what you intended to happen. (1) Replacemakeatotherx
withmakeatother
. (2) Either don't useitem
at all or wrap it into anbeginitemize...enditemize
.
â moewe
Sep 22 at 14:29
1
no space shows if you follow @moewe advice to additemize
environment to wrap around the entire contents of subsubsection Saint-Julien
â jfbu
Sep 22 at 14:36
 |Â
show 10 more comments
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I am making a wine list from a CSV file (see my first question here: How to import data from excel and format it as text in LaTeX?) and I need to align the prices on the right.
To do this, I used the datatool
package to fetch the informations from my spreadsheet, DTLforeach
to iterate what I wanted to do and hfill
to align my prices on the right. (see code after the picture)
As you can see on the picture, it worked very well for every line but the last one of each (subsub)section, which is slightly misaligned:
Here is my code:
documentclass[12pt]article
usepackage[utf8]inputenc
% Pour modifer les marges
usepackagegeometry
% Marges du document
geometryhmargin=1.5cm,vmargin=1.5cm
% To remove the heading of the table of contents ("Contents")
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother %%% WAS makeatotherx = ERROR %%%
% To make itemized lists
% This package provides user control over the layout of the three basic list environments: enumerate, itemize and description. It supersedes both enumerate and mdwlist (providing well-structured replacements for all their funtionality), and in addition provides functions to compute the layout of labels, and to âÂÂcloneâ the standard environments, to create new environments with counters of their own.
usepackageenumitem
% Datatool package to load external files (csv)
usepackagedatatool
%--------------------------%
titleCarte des Vins
authorB
datetoday
%--------------------------%
setcountersecnumdepth-2
begindocument
maketitle
tableofcontents
%--------------------------%
newpage
sectionBordeaux
% Load CSV database (here bordeaux.csv)
% and give it a label (here BOR)
DTLloaddbBORbordeaux.csv
subsectionRed
%%%%%%% CUT CODE %%%%%%%%%%%%%%%%%%%%%%%%%
newpage
subsubsectionSaint-Julien
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
beginitemize %%% ABSENT IN MY ORIGINAL CODE %%%
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
enditemize %%% ABSENT IN MY ORIGINAL CODE %%%
%%%%%%%%%%%%%%%
subsubsectionMargaux
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Margaux (R04)
%%%%%%%%%%%%%%%%% CUT CODE%%%%%%%
enddocument
How can I align all my prices on the right?
Excerpt of my CSV file:
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
horizontal-alignment formatting datatool
I am making a wine list from a CSV file (see my first question here: How to import data from excel and format it as text in LaTeX?) and I need to align the prices on the right.
To do this, I used the datatool
package to fetch the informations from my spreadsheet, DTLforeach
to iterate what I wanted to do and hfill
to align my prices on the right. (see code after the picture)
As you can see on the picture, it worked very well for every line but the last one of each (subsub)section, which is slightly misaligned:
Here is my code:
documentclass[12pt]article
usepackage[utf8]inputenc
% Pour modifer les marges
usepackagegeometry
% Marges du document
geometryhmargin=1.5cm,vmargin=1.5cm
% To remove the heading of the table of contents ("Contents")
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother %%% WAS makeatotherx = ERROR %%%
% To make itemized lists
% This package provides user control over the layout of the three basic list environments: enumerate, itemize and description. It supersedes both enumerate and mdwlist (providing well-structured replacements for all their funtionality), and in addition provides functions to compute the layout of labels, and to âÂÂcloneâ the standard environments, to create new environments with counters of their own.
usepackageenumitem
% Datatool package to load external files (csv)
usepackagedatatool
%--------------------------%
titleCarte des Vins
authorB
datetoday
%--------------------------%
setcountersecnumdepth-2
begindocument
maketitle
tableofcontents
%--------------------------%
newpage
sectionBordeaux
% Load CSV database (here bordeaux.csv)
% and give it a label (here BOR)
DTLloaddbBORbordeaux.csv
subsectionRed
%%%%%%% CUT CODE %%%%%%%%%%%%%%%%%%%%%%%%%
newpage
subsubsectionSaint-Julien
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
beginitemize %%% ABSENT IN MY ORIGINAL CODE %%%
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
enditemize %%% ABSENT IN MY ORIGINAL CODE %%%
%%%%%%%%%%%%%%%
subsubsectionMargaux
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Margaux (R04)
%%%%%%%%%%%%%%%%% CUT CODE%%%%%%%
enddocument
How can I align all my prices on the right?
Excerpt of my CSV file:
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
horizontal-alignment formatting datatool
horizontal-alignment formatting datatool
edited Sep 22 at 14:46
asked Sep 22 at 13:51
Claire Boitet
639
639
1
Unfortunately the code as shown can't be run (a good MWE for LaTeX should start withdocumentclass
and should have abegindocument...enddocument
pair, in this case it would also help if you could supply example.csv
data, see tex.meta.stackexchange.com/q/228/35864), so I can only guess that you are missing a%
somewhere.
â moewe
Sep 22 at 13:52
3
I did compile your document here... Have you noticed you are getting lots of compilation errors? You really shouldn't ignore these. Your code is doing anitem
without being wrapped in a list environment (and this is adding a space after the last entry). Try addingbeginitemize
before theDTLforeach
command and anenditemize
after it. The output should look right then. Ooh, and you have a typo. You havemakeatotherx
, with an extrax
.
â Phelype Oleinik
Sep 22 at 14:20
2
I get two kinds of errors: (1)! Undefined control sequence. l.28 makeatotherx
. It should have beenmakeatother
instead. (2)! LaTeX Error: Lonely item--perhaps a missing list environment.
. This is because you haveitem
in your code when there is noitemize
orenumerate
to make use of it. That causes an error.
â moewe
Sep 22 at 14:23
2
Yes, but errors must be fixed even if superficially they don't affect the PDF - the absolutely affect the output. TeX has a limited ability to recover from errors, but usually it has to guess what to do and that is rarely exactly what you intended to happen. (1) Replacemakeatotherx
withmakeatother
. (2) Either don't useitem
at all or wrap it into anbeginitemize...enditemize
.
â moewe
Sep 22 at 14:29
1
no space shows if you follow @moewe advice to additemize
environment to wrap around the entire contents of subsubsection Saint-Julien
â jfbu
Sep 22 at 14:36
 |Â
show 10 more comments
1
Unfortunately the code as shown can't be run (a good MWE for LaTeX should start withdocumentclass
and should have abegindocument...enddocument
pair, in this case it would also help if you could supply example.csv
data, see tex.meta.stackexchange.com/q/228/35864), so I can only guess that you are missing a%
somewhere.
â moewe
Sep 22 at 13:52
3
I did compile your document here... Have you noticed you are getting lots of compilation errors? You really shouldn't ignore these. Your code is doing anitem
without being wrapped in a list environment (and this is adding a space after the last entry). Try addingbeginitemize
before theDTLforeach
command and anenditemize
after it. The output should look right then. Ooh, and you have a typo. You havemakeatotherx
, with an extrax
.
â Phelype Oleinik
Sep 22 at 14:20
2
I get two kinds of errors: (1)! Undefined control sequence. l.28 makeatotherx
. It should have beenmakeatother
instead. (2)! LaTeX Error: Lonely item--perhaps a missing list environment.
. This is because you haveitem
in your code when there is noitemize
orenumerate
to make use of it. That causes an error.
â moewe
Sep 22 at 14:23
2
Yes, but errors must be fixed even if superficially they don't affect the PDF - the absolutely affect the output. TeX has a limited ability to recover from errors, but usually it has to guess what to do and that is rarely exactly what you intended to happen. (1) Replacemakeatotherx
withmakeatother
. (2) Either don't useitem
at all or wrap it into anbeginitemize...enditemize
.
â moewe
Sep 22 at 14:29
1
no space shows if you follow @moewe advice to additemize
environment to wrap around the entire contents of subsubsection Saint-Julien
â jfbu
Sep 22 at 14:36
1
1
Unfortunately the code as shown can't be run (a good MWE for LaTeX should start with
documentclass
and should have a begindocument...enddocument
pair, in this case it would also help if you could supply example .csv
data, see tex.meta.stackexchange.com/q/228/35864), so I can only guess that you are missing a %
somewhere.â moewe
Sep 22 at 13:52
Unfortunately the code as shown can't be run (a good MWE for LaTeX should start with
documentclass
and should have a begindocument...enddocument
pair, in this case it would also help if you could supply example .csv
data, see tex.meta.stackexchange.com/q/228/35864), so I can only guess that you are missing a %
somewhere.â moewe
Sep 22 at 13:52
3
3
I did compile your document here... Have you noticed you are getting lots of compilation errors? You really shouldn't ignore these. Your code is doing an
item
without being wrapped in a list environment (and this is adding a space after the last entry). Try adding beginitemize
before the DTLforeach
command and an enditemize
after it. The output should look right then. Ooh, and you have a typo. You have makeatotherx
, with an extra x
.â Phelype Oleinik
Sep 22 at 14:20
I did compile your document here... Have you noticed you are getting lots of compilation errors? You really shouldn't ignore these. Your code is doing an
item
without being wrapped in a list environment (and this is adding a space after the last entry). Try adding beginitemize
before the DTLforeach
command and an enditemize
after it. The output should look right then. Ooh, and you have a typo. You have makeatotherx
, with an extra x
.â Phelype Oleinik
Sep 22 at 14:20
2
2
I get two kinds of errors: (1)
! Undefined control sequence. l.28 makeatotherx
. It should have been makeatother
instead. (2) ! LaTeX Error: Lonely item--perhaps a missing list environment.
. This is because you have item
in your code when there is no itemize
or enumerate
to make use of it. That causes an error.â moewe
Sep 22 at 14:23
I get two kinds of errors: (1)
! Undefined control sequence. l.28 makeatotherx
. It should have been makeatother
instead. (2) ! LaTeX Error: Lonely item--perhaps a missing list environment.
. This is because you have item
in your code when there is no itemize
or enumerate
to make use of it. That causes an error.â moewe
Sep 22 at 14:23
2
2
Yes, but errors must be fixed even if superficially they don't affect the PDF - the absolutely affect the output. TeX has a limited ability to recover from errors, but usually it has to guess what to do and that is rarely exactly what you intended to happen. (1) Replace
makeatotherx
with makeatother
. (2) Either don't use item
at all or wrap it into an beginitemize...enditemize
.â moewe
Sep 22 at 14:29
Yes, but errors must be fixed even if superficially they don't affect the PDF - the absolutely affect the output. TeX has a limited ability to recover from errors, but usually it has to guess what to do and that is rarely exactly what you intended to happen. (1) Replace
makeatotherx
with makeatother
. (2) Either don't use item
at all or wrap it into an beginitemize...enditemize
.â moewe
Sep 22 at 14:29
1
1
no space shows if you follow @moewe advice to add
itemize
environment to wrap around the entire contents of subsubsection Saint-Julienâ jfbu
Sep 22 at 14:36
no space shows if you follow @moewe advice to add
itemize
environment to wrap around the entire contents of subsubsection Saint-Julienâ jfbu
Sep 22 at 14:36
 |Â
show 10 more comments
2 Answers
2
active
oldest
votes
up vote
7
down vote
accepted
There are two obvious problems with your code. You get errors about both of them.
Firstly you mistyped
makeatother
as makeatotherx
which causes LaTeX to complain
! Undefined control sequence.
l.22 makeatotherx
Secondly your loop code in DTLforeach
calls item
but there is no surrounding list environment that would know how to deal with it.
Since you want to use item
to get a new line, I suggest a plain trivlist
in this case.
%RequirePackagefilecontents
beginfilecontents*bordeaux.csv
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
endfilecontents*
documentclass[12pt]article
usepackage[utf8]inputenc
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother
usepackageenumitem
usepackagedatatool
begindocument
sectionBordeaux
DTLloaddbBORbordeaux.csv
subsectionRed
subsubsectionSaint-Julien
begintrivlist
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
endtrivlist
enddocument
Possibly a table (tabular
) would be a better fit.
add a comment |Â
up vote
5
down vote
Apart from the problem in the code, the root issue is that CostPrice
always has an ending space, as one can see by using textttmeaningCostPrice+++
.
This comes from the fact that your csv data has spaces before the commas, as datatool
doesn't trim leading or trailing spaces.
Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed
from either side of the separators. (p. 46 of thedatatool
user manual)
Thanks to @NicolaTalbot who kindly pointed it out in a comment.
Here is an excerpt of your data file:
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
where the spaces show around the monetary items.
With the following (from @moewe's comment to OP)
beginitemize
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%%%%%%%%%%%%%%%
enditemize
there is no problem
The extra space doesnt show then. (it is suppressed by item paragraph)
Remark: in fact even with your buggy code you could have avoided the sapce this way:
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%<----- suppress space from line end
%%%%%%%%%%%%%%%
Because then there is only ONE not TWO space tokens at the end of paragraph. Of course much better is to wrap in itemize
else item
is illegal.
datatool
doesn't trim leading or trailing spaces. (p. 46 of the user manual: "Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed from either side of the separators.")
â Nicola Talbot
Sep 22 at 17:09
@NicolaTalbot ok! (if you ever need it,xinttools
hasxintZapSpaces
which in two expansion steps removes leading and trailing spaces of its argument#1
; you need someexpandafter
if#1
isFoo
, to unpack its contents, so typicallyoodefFooStrippedexpandafterxintZapSpacesexpandafterFoo
whereoodef
isxint
's lingua for two expansions) (page 174 ofxint.pdf
doc)
â jfbu
Sep 22 at 17:44
Okay, that's useful to know. Thanks.
â Nicola Talbot
Sep 22 at 18:02
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
7
down vote
accepted
There are two obvious problems with your code. You get errors about both of them.
Firstly you mistyped
makeatother
as makeatotherx
which causes LaTeX to complain
! Undefined control sequence.
l.22 makeatotherx
Secondly your loop code in DTLforeach
calls item
but there is no surrounding list environment that would know how to deal with it.
Since you want to use item
to get a new line, I suggest a plain trivlist
in this case.
%RequirePackagefilecontents
beginfilecontents*bordeaux.csv
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
endfilecontents*
documentclass[12pt]article
usepackage[utf8]inputenc
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother
usepackageenumitem
usepackagedatatool
begindocument
sectionBordeaux
DTLloaddbBORbordeaux.csv
subsectionRed
subsubsectionSaint-Julien
begintrivlist
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
endtrivlist
enddocument
Possibly a table (tabular
) would be a better fit.
add a comment |Â
up vote
7
down vote
accepted
There are two obvious problems with your code. You get errors about both of them.
Firstly you mistyped
makeatother
as makeatotherx
which causes LaTeX to complain
! Undefined control sequence.
l.22 makeatotherx
Secondly your loop code in DTLforeach
calls item
but there is no surrounding list environment that would know how to deal with it.
Since you want to use item
to get a new line, I suggest a plain trivlist
in this case.
%RequirePackagefilecontents
beginfilecontents*bordeaux.csv
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
endfilecontents*
documentclass[12pt]article
usepackage[utf8]inputenc
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother
usepackageenumitem
usepackagedatatool
begindocument
sectionBordeaux
DTLloaddbBORbordeaux.csv
subsectionRed
subsubsectionSaint-Julien
begintrivlist
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
endtrivlist
enddocument
Possibly a table (tabular
) would be a better fit.
add a comment |Â
up vote
7
down vote
accepted
up vote
7
down vote
accepted
There are two obvious problems with your code. You get errors about both of them.
Firstly you mistyped
makeatother
as makeatotherx
which causes LaTeX to complain
! Undefined control sequence.
l.22 makeatotherx
Secondly your loop code in DTLforeach
calls item
but there is no surrounding list environment that would know how to deal with it.
Since you want to use item
to get a new line, I suggest a plain trivlist
in this case.
%RequirePackagefilecontents
beginfilecontents*bordeaux.csv
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
endfilecontents*
documentclass[12pt]article
usepackage[utf8]inputenc
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother
usepackageenumitem
usepackagedatatool
begindocument
sectionBordeaux
DTLloaddbBORbordeaux.csv
subsectionRed
subsubsectionSaint-Julien
begintrivlist
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
endtrivlist
enddocument
Possibly a table (tabular
) would be a better fit.
There are two obvious problems with your code. You get errors about both of them.
Firstly you mistyped
makeatother
as makeatotherx
which causes LaTeX to complain
! Undefined control sequence.
l.22 makeatotherx
Secondly your loop code in DTLforeach
calls item
but there is no surrounding list environment that would know how to deal with it.
Since you want to use item
to get a new line, I suggest a plain trivlist
in this case.
%RequirePackagefilecontents
beginfilecontents*bordeaux.csv
CODE,Vintage,Name,Classification,Origin,Size,Type,Wine,Region,Stockholding,CostPrice,TOTCostPrice,TOTCostPriceBis
GRUAUD LAROSE,1971,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã15.00 , ã30.00 , ã30.00
LALANDE BORIE,2011,Château Lalande-Borie,,Saint-Julien,Bottle,Red,Bordeaux,R03,35.0, ã19.70 , ã689.50 , ã689.50
RESERVE LEOV-BARTN,2011,La Réserve de Léoville Barton,,Saint-Julien,Bottle,Red,Bordeaux,R03,12.0, ã20.86 , ã250.32 , ã250.32
CLOS DU MARQUIS,2004,Clos du Marquis,,Saint-Julien,Bottle,Red,Bordeaux,R03,3.0, ã35.83 , ã107.49 , ã107.49
GRUAUD LAROSE,2005,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,16.0, ã43.49 , ã695.84 , ã695.84
DUCRU BEAUCAILLOU,1978,Château Ducru-Beaucaillou,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã56.52 , ã113.04 , ã113.04
LAGRANGE 3EME SJ,2005,Château Lagrange,3ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,6.0, ã58.75 , ã352.50 , ã352.50
LEOVILLE POYFERRE,2000,Château Léoville Poyferre,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,2.0, ã73.33 , ã146.66 , ã146.66
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
endfilecontents*
documentclass[12pt]article
usepackage[utf8]inputenc
makeatletter
renewcommandtableofcontents%
@starttoctoc%
makeatother
usepackageenumitem
usepackagedatatool
begindocument
sectionBordeaux
DTLloaddbBORbordeaux.csv
subsectionRed
subsubsectionSaint-Julien
begintrivlist
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
endtrivlist
enddocument
Possibly a table (tabular
) would be a better fit.
answered Sep 22 at 14:37
moewe
77.8k797296
77.8k797296
add a comment |Â
add a comment |Â
up vote
5
down vote
Apart from the problem in the code, the root issue is that CostPrice
always has an ending space, as one can see by using textttmeaningCostPrice+++
.
This comes from the fact that your csv data has spaces before the commas, as datatool
doesn't trim leading or trailing spaces.
Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed
from either side of the separators. (p. 46 of thedatatool
user manual)
Thanks to @NicolaTalbot who kindly pointed it out in a comment.
Here is an excerpt of your data file:
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
where the spaces show around the monetary items.
With the following (from @moewe's comment to OP)
beginitemize
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%%%%%%%%%%%%%%%
enditemize
there is no problem
The extra space doesnt show then. (it is suppressed by item paragraph)
Remark: in fact even with your buggy code you could have avoided the sapce this way:
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%<----- suppress space from line end
%%%%%%%%%%%%%%%
Because then there is only ONE not TWO space tokens at the end of paragraph. Of course much better is to wrap in itemize
else item
is illegal.
datatool
doesn't trim leading or trailing spaces. (p. 46 of the user manual: "Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed from either side of the separators.")
â Nicola Talbot
Sep 22 at 17:09
@NicolaTalbot ok! (if you ever need it,xinttools
hasxintZapSpaces
which in two expansion steps removes leading and trailing spaces of its argument#1
; you need someexpandafter
if#1
isFoo
, to unpack its contents, so typicallyoodefFooStrippedexpandafterxintZapSpacesexpandafterFoo
whereoodef
isxint
's lingua for two expansions) (page 174 ofxint.pdf
doc)
â jfbu
Sep 22 at 17:44
Okay, that's useful to know. Thanks.
â Nicola Talbot
Sep 22 at 18:02
add a comment |Â
up vote
5
down vote
Apart from the problem in the code, the root issue is that CostPrice
always has an ending space, as one can see by using textttmeaningCostPrice+++
.
This comes from the fact that your csv data has spaces before the commas, as datatool
doesn't trim leading or trailing spaces.
Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed
from either side of the separators. (p. 46 of thedatatool
user manual)
Thanks to @NicolaTalbot who kindly pointed it out in a comment.
Here is an excerpt of your data file:
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
where the spaces show around the monetary items.
With the following (from @moewe's comment to OP)
beginitemize
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%%%%%%%%%%%%%%%
enditemize
there is no problem
The extra space doesnt show then. (it is suppressed by item paragraph)
Remark: in fact even with your buggy code you could have avoided the sapce this way:
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%<----- suppress space from line end
%%%%%%%%%%%%%%%
Because then there is only ONE not TWO space tokens at the end of paragraph. Of course much better is to wrap in itemize
else item
is illegal.
datatool
doesn't trim leading or trailing spaces. (p. 46 of the user manual: "Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed from either side of the separators.")
â Nicola Talbot
Sep 22 at 17:09
@NicolaTalbot ok! (if you ever need it,xinttools
hasxintZapSpaces
which in two expansion steps removes leading and trailing spaces of its argument#1
; you need someexpandafter
if#1
isFoo
, to unpack its contents, so typicallyoodefFooStrippedexpandafterxintZapSpacesexpandafterFoo
whereoodef
isxint
's lingua for two expansions) (page 174 ofxint.pdf
doc)
â jfbu
Sep 22 at 17:44
Okay, that's useful to know. Thanks.
â Nicola Talbot
Sep 22 at 18:02
add a comment |Â
up vote
5
down vote
up vote
5
down vote
Apart from the problem in the code, the root issue is that CostPrice
always has an ending space, as one can see by using textttmeaningCostPrice+++
.
This comes from the fact that your csv data has spaces before the commas, as datatool
doesn't trim leading or trailing spaces.
Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed
from either side of the separators. (p. 46 of thedatatool
user manual)
Thanks to @NicolaTalbot who kindly pointed it out in a comment.
Here is an excerpt of your data file:
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
where the spaces show around the monetary items.
With the following (from @moewe's comment to OP)
beginitemize
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%%%%%%%%%%%%%%%
enditemize
there is no problem
The extra space doesnt show then. (it is suppressed by item paragraph)
Remark: in fact even with your buggy code you could have avoided the sapce this way:
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%<----- suppress space from line end
%%%%%%%%%%%%%%%
Because then there is only ONE not TWO space tokens at the end of paragraph. Of course much better is to wrap in itemize
else item
is illegal.
Apart from the problem in the code, the root issue is that CostPrice
always has an ending space, as one can see by using textttmeaningCostPrice+++
.
This comes from the fact that your csv data has spaces before the commas, as datatool
doesn't trim leading or trailing spaces.
Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed
from either side of the separators. (p. 46 of thedatatool
user manual)
Thanks to @NicolaTalbot who kindly pointed it out in a comment.
Here is an excerpt of your data file:
GRUARD LAROSE,1986,Château Gruaud-Larose,2ème Grand Cru Classé ,Saint-Julien,Bottle,Red,Bordeaux,R03,1.0, ã100.00 , ã100.00 , ã100.00
where the spaces show around the monetary items.
With the following (from @moewe's comment to OP)
beginitemize
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%%%%%%%%%%%%%%%
enditemize
there is no problem
The extra space doesnt show then. (it is suppressed by item paragraph)
Remark: in fact even with your buggy code you could have avoided the sapce this way:
%%%%%%%%%%%%%%%
% Iteration for Bordeaux Red Saint-Julien (R03)
DTLforeach*[DTLiseqRegionR03] % Condition
BOR % Database label
Vintage=Vintage,Name=Name,Classification=Classification,Type=Type,Origin=Origin,Region=Region,CostPrice=CostPrice % Assignment
% Stuff to do at each iteration:
item
textbfVintage
textbf Name
textit Classification
hfillCostPrice
%<----- suppress space from line end
%%%%%%%%%%%%%%%
Because then there is only ONE not TWO space tokens at the end of paragraph. Of course much better is to wrap in itemize
else item
is illegal.
edited Sep 22 at 18:13
answered Sep 22 at 14:42
jfbu
42.6k64138
42.6k64138
datatool
doesn't trim leading or trailing spaces. (p. 46 of the user manual: "Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed from either side of the separators.")
â Nicola Talbot
Sep 22 at 17:09
@NicolaTalbot ok! (if you ever need it,xinttools
hasxintZapSpaces
which in two expansion steps removes leading and trailing spaces of its argument#1
; you need someexpandafter
if#1
isFoo
, to unpack its contents, so typicallyoodefFooStrippedexpandafterxintZapSpacesexpandafterFoo
whereoodef
isxint
's lingua for two expansions) (page 174 ofxint.pdf
doc)
â jfbu
Sep 22 at 17:44
Okay, that's useful to know. Thanks.
â Nicola Talbot
Sep 22 at 18:02
add a comment |Â
datatool
doesn't trim leading or trailing spaces. (p. 46 of the user manual: "Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed from either side of the separators.")
â Nicola Talbot
Sep 22 at 17:09
@NicolaTalbot ok! (if you ever need it,xinttools
hasxintZapSpaces
which in two expansion steps removes leading and trailing spaces of its argument#1
; you need someexpandafter
if#1
isFoo
, to unpack its contents, so typicallyoodefFooStrippedexpandafterxintZapSpacesexpandafterFoo
whereoodef
isxint
's lingua for two expansions) (page 174 ofxint.pdf
doc)
â jfbu
Sep 22 at 17:44
Okay, that's useful to know. Thanks.
â Nicola Talbot
Sep 22 at 18:02
datatool
doesn't trim leading or trailing spaces. (p. 46 of the user manual: "Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed from either side of the separators.")â Nicola Talbot
Sep 22 at 17:09
datatool
doesn't trim leading or trailing spaces. (p. 46 of the user manual: "Note that spaces count in the usual TeX manner and wonâÂÂt be trimmed from either side of the separators.")â Nicola Talbot
Sep 22 at 17:09
@NicolaTalbot ok! (if you ever need it,
xinttools
has xintZapSpaces
which in two expansion steps removes leading and trailing spaces of its argument #1
; you need some expandafter
if #1
is Foo
, to unpack its contents, so typically oodefFooStrippedexpandafterxintZapSpacesexpandafterFoo
where oodef
is xint
's lingua for two expansions) (page 174 of xint.pdf
doc)â jfbu
Sep 22 at 17:44
@NicolaTalbot ok! (if you ever need it,
xinttools
has xintZapSpaces
which in two expansion steps removes leading and trailing spaces of its argument #1
; you need some expandafter
if #1
is Foo
, to unpack its contents, so typically oodefFooStrippedexpandafterxintZapSpacesexpandafterFoo
where oodef
is xint
's lingua for two expansions) (page 174 of xint.pdf
doc)â jfbu
Sep 22 at 17:44
Okay, that's useful to know. Thanks.
â Nicola Talbot
Sep 22 at 18:02
Okay, that's useful to know. Thanks.
â Nicola Talbot
Sep 22 at 18:02
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f451982%2fhow-to-align-the-last-element-on-the-right-when-using-hfill%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Unfortunately the code as shown can't be run (a good MWE for LaTeX should start with
documentclass
and should have abegindocument...enddocument
pair, in this case it would also help if you could supply example.csv
data, see tex.meta.stackexchange.com/q/228/35864), so I can only guess that you are missing a%
somewhere.â moewe
Sep 22 at 13:52
3
I did compile your document here... Have you noticed you are getting lots of compilation errors? You really shouldn't ignore these. Your code is doing an
item
without being wrapped in a list environment (and this is adding a space after the last entry). Try addingbeginitemize
before theDTLforeach
command and anenditemize
after it. The output should look right then. Ooh, and you have a typo. You havemakeatotherx
, with an extrax
.â Phelype Oleinik
Sep 22 at 14:20
2
I get two kinds of errors: (1)
! Undefined control sequence. l.28 makeatotherx
. It should have beenmakeatother
instead. (2)! LaTeX Error: Lonely item--perhaps a missing list environment.
. This is because you haveitem
in your code when there is noitemize
orenumerate
to make use of it. That causes an error.â moewe
Sep 22 at 14:23
2
Yes, but errors must be fixed even if superficially they don't affect the PDF - the absolutely affect the output. TeX has a limited ability to recover from errors, but usually it has to guess what to do and that is rarely exactly what you intended to happen. (1) Replace
makeatotherx
withmakeatother
. (2) Either don't useitem
at all or wrap it into anbeginitemize...enditemize
.â moewe
Sep 22 at 14:29
1
no space shows if you follow @moewe advice to add
itemize
environment to wrap around the entire contents of subsubsection Saint-Julienâ jfbu
Sep 22 at 14:36