I am quite new to LaTeX and I am making a wine menu.
In some cases I need to add a price for a single glass and/or for a half-carafe... But ONLY in these cases, when such an option exists.
I found some answers to my questions here, and opted for the \usepackage{makecell} and makecell[]{} strategy:
How to add a forced line break inside a table cell
How to break a line in a table [duplicate]
Here is my code:
\documentclass{article}
\usepackage[utf8]{inputenc}
% ----- TO MODIFY MARGINS -----%%
\usepackage{geometry}
% Marges du document
\geometry{hmargin=0.25cm,vmargin=2.5cm}
%\usepackage[left=0.5cm, right=0cm, top=2.5cm, bottom=2.5cm]{geometry}
% To change the MARGINS with \begin{adjustwidth}{Xcm}{Xcm}
\usepackage{changepage}
% DATATOOL package to load and create external data files (csv)
\usepackage{datatool}
% ------ To make TABLES ------%%
\usepackage{array}
\usepackage{tabularx,ragged2e}
% Pour ajuster les tables trop grandes
\usepackage{adjustbox}
% To force a line break in a cell
\usepackage{makecell}
%--------------------------%
% Load CSV database (here Coravin.csv)
% and give it a label (here WIN)
\DTLloaddb{WIN}{Coravin.csv}
%--------------------------------------------%
\title{Test to break line in a table}
\author{CB}
\date{October 2018}
\begin{document}
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Iteration for Coravin
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent
\begin{tabularx}{\linewidth}{
% @{} % no \tabcolsep on the left side
>{\RaggedRight}p{0.65cm} % SizeCode
% @{} % no \tabcolsep
>{\RaggedRight}p{2cm} % Vintage
X % Name Classification NameB Grower & Origin
% @{} % no \tabcolsep
>{\RaggedLeft}p{1.25cm} % Price
>{\RaggedRight}p{1.9cm} % SizeBis
@{} % no \tabcolsep on the right side
}%
\DTLforeach*[\DTLiseq{\Coravin}{X}] % Condition
{WIN} % Database label
{\Vintage=Vintage,\Name=Name,\Classification=Classification,\NameB=NameB,\Grower=Grower,\Origin=(Origin),\Region=Region,\Subregion=Subregion,\SellPrice=SellPrice,\GlassPrice=GlassPrice,\HalfCarafePrice=HalfCarafePrice,\Coravin=Coravin,\Bin=Bin,\SizeBis=SizeBis} % Assignment
{% Stuff to do at each iteration:
\makecell[l]{\small{\textbf{\Bin}} \\ \\} &
\makecell[l]{\textbf{\Vintage} \\ \\} &
\makecell[l]{\textbf{\Name}
\textit{\Classification}
\textbf{\NameB} \textbf{\Grower} \\ \\} &
\makecell[l]{\textit{\pounds\SellPrice} \\ \textit{\pounds\HalfCarafePrice} \\ \textit{\pounds\GlassPrice}} &
\makecell[l]{\footnotesize{\SizeBis} \\ \footnotesize{Half Carafe} \\ \footnotesize{Glass}} \\
}%
\end{tabularx}%
%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
And this is what I get so far, which is a good beginning to me:

However I still have some issues:
- I would like the lines with the glass and/or half-carafe prices and the "Glass" an/or "Half-Carafe" text to appear ONLY when these prices exist.
- The alignment of the first price (usually a bottle, which is assumed, or something else such as a Half, a 50cL, a Magnum or a Double Magnum, which in this case is specified) with the Vintage + Name of the wine doesn't seem to be right.
=> How do I solve these problems?
I am aware that what I am asking for might require the use of something like a loop with if and else... But as my original file is already very big and takes a while to compile I would like to avoid it IF POSSIBLE. If not then... Well, I'd use it. ^^'
Here is the csv excerpt which I used to make this MWE:
Vintage,Name,Classification,NameB,Grower,Quantity,Origin,(Origin),Area,Region,Subregion,Type,Wine,Bin,Xsizes,SizeBis,SizeCode,UnitPerCase,Coef,CostPrice,SellPrice,SellPriceB,ClubPrice,HalfCarafePrice,GlassPrice,HouseWines,LowStock,Coravin
2011,La Réserve de Léoville Barton,2ème vin de Château Léoville Barton,,,,Saint-Julien,(Saint-Julien),Saint-Julien,R03,R03,Red,Bordeaux,,,,,12,1,20.86,34,34,,,X,,,X
2009,Château Poujeaux,Cru Bourgeois Exceptionnel,,,,Moulis-en-Médoc,(Moulis-en-Médoc),Médoc,R06,R06,Red,Bordeaux,,,,,12,1,26.62,47,47,,,X,,,X
2009,Château Dassault,Grand Cru,,,,Saint-Émilion,(Saint-Émilion),Saint-Émilion,R07,R07,Red,Bordeaux,,,,,12,1,32.49,59,59,,,X,,,X
2005,Royal Tokaji Aszu 5 Puttonyos,,,,,Hungary,(Hungary),Sweet Wines,R11,R11,Sweet,ROW,950,,50 cl,,24,2,13.75,29,58,29,,6,,,X
2001,Château Lafaurie-Peyraguey,1er Grand Cru Classé,,,,Sauternes,(Sauternes),Sweet Wines,R11,R11,Sweet,Bordeaux,139,O,Half,H,24,2,14.00,35,70,,,13,,,X
2011,Fonseca,Late Bottled Vintage Port,,,,Portugal,(Portugal),Port,R12,R12,Red,Port,1400,,,,12,1,9.72,22,22,22,11,4,,,X
1998,Fonseca Guimaraens,Bottled in 2000,,,,Portugal,(Portugal),Port,R12,R12,Red,Port,1404,,,,12,1,16.50,34,34,34,18,7,,,X
20 year old,Taylor's,Tawny Port,,,,Portugal,(Portugal),Port,R12,R12,Red,Port,1405,,,,12,1,23.29,46,46,46,,8,,,X
1994,Croft,,,,,Portugal,(Portugal),Port,R12,R12,Red,Port,1401,,,,12,1,30.00,50,50,65,25,10,,,X
2009,Gevrey-Chambertin,,Champs Cheny,Dom. Philippe Roty,,Gevrey-Chambertin,(Gevrey-Chambertin),Côte-de-Nuits,R22,R220,Red,Burgundy,,,,,12,1,39.67,60,60,,,X,,,X
2015,Santenay Blanc,,,Dom. Bachelet Monnot,,Santenay,(Santenay),Côte-de-Beaune,R31,R313,White,Burgundy,655,,,,12,1,20.50,35,35,40,,X,,,X

textbfintobfseriesandtextitintoitshape. For example\small{\textbf{\Bin}}became\small\bfseries \Binand\textit{\Classification}became\itshape \Classification. As both codes seem to work, why did you change it? Is it a new syntax and mine is obsolete? – Claire Boitet Oct 29 '18 at 19:33tabularforms a group, so issuing\bfseriesor\itshapeis limited by the terminating&or\\. Also, one should use{\small ...}, not\small{...}since\smallis a font declaration, not a macro that takes an argument. With all that I thought I'd save some keystrokes by removing the braces{...}as well. You can use\textbf{...}or\textit{...}or{\bfseries ...}or{\itshape ...}. – Werner Oct 29 '18 at 19:38\textbf{\NameB}\textbf{\Grower}for{\bfseries \NameB{} \Grower}... Why is there a pair of curly braces{}after the\NameB? (Sorry if these questions are trite or trivial, I'm really a beginner. ^^' ) – Claire Boitet Oct 29 '18 at 20:01The normal spacing before I added the Glass and Half-Carafe prices: https://i.stack.imgur.com/84IaR.png The increased spacing after I added the Glass and Half-Carafe prices: https://i.stack.imgur.com/1fwAG.png
– Claire Boitet Oct 31 '18 at 16:45