Published by Patrick Mutisya · 14 days ago
Be able to align data and labels appropriately, including right‑aligning numeric data and aligning decimal points in tables.
In a database report you can use an HTML <table> to control alignment. The align attribute on <td> (or <th>) can be set to left, center or right. For decimal alignment, place the whole number and the fractional part in separate cells, or use a fixed‑width font and right‑align the whole cell.
| Item | Quantity | Price (£) |
|---|---|---|
| Notebook | 12 | 1.50 |
| Pen | 30 | 0.45 |
| Calculator | 5 | 12.99 |
One common technique is to split the number into two cells: the integer part (right‑aligned) and the fractional part (left‑aligned). This forces the decimal points to line up.
| Product | Units | Unit Price (£) | |
|---|---|---|---|
| Whole | .Fraction | ||
| Desk | 3 | 85 | .00 |
| Chair | 12 | 45 | .50 |
| Lamp | 7 | 22 | .75 |
When demonstrating calculations, embed LaTeX expressions between \$...\$ for inline or \$...\$ for displayed equations.
Example of a total price calculation:
\$\text{Total} = \sum{i=1}^{n} (\text{Quantity}i \times \text{Price}_i)\$
For the table above, the total for the Desk line would be:
\$\text{Total}_{\text{Desk}} = 3 \times 85.00 = 255.00\$
Create a report for the following sales data. Align the columns as described.
Include a column for Subtotal (Quantity × Unit Price) and a final row for Grand Total. Use right alignment for all numeric columns and ensure the decimal points line up.