Reserve outer tabcolsep margins around tables
This commit is contained in:
1 parent
20d23ce68d
commit
aa072f58d8
5 files changed
+52
-12
No files matched your search
@@ -169,6 +169,9 @@ pub struct Halign {
|
||||
/// Trailing rows painted only on the last page (`\endfoot`/`\endlastfoot`).
|
||||
#[serde(default)]
|
||||
pub foot_len: usize,
|
||||
/// Space reserved at the left and right edges (outer `\tabcolsep` margins).
|
||||
#[serde(default)]
|
||||
pub margin: i64,
|
||||
pub width: i64,
|
||||
pub height: i64,
|
||||
pub line_height: i64,
|
||||
@@ -328,6 +331,7 @@ impl Halign {
|
||||
first_head_len: 0,
|
||||
head_len: 0,
|
||||
foot_len: 0,
|
||||
margin: self.margin,
|
||||
width: self.width,
|
||||
height,
|
||||
line_height: self.line_height,
|
||||
@@ -366,6 +370,7 @@ impl Halign {
|
||||
first_head_len: 0,
|
||||
head_len: 0,
|
||||
foot_len: 0,
|
||||
margin: self.margin,
|
||||
width: self.width,
|
||||
height,
|
||||
line_height: self.line_height,
|
||||
@@ -390,6 +395,7 @@ impl Halign {
|
||||
first_head_len: 0,
|
||||
head_len: 0,
|
||||
foot_len: 0,
|
||||
margin: self.margin,
|
||||
width: self.width,
|
||||
height,
|
||||
line_height: self.line_height,
|
||||
@@ -441,7 +447,8 @@ impl Halign {
|
||||
.iter()
|
||||
.sum::<i64>()
|
||||
+ gaps;
|
||||
let x: i64 = self.column_widths[..column].iter().sum::<i64>()
|
||||
let x: i64 = self.margin
|
||||
+ self.column_widths[..column].iter().sum::<i64>()
|
||||
+ (0..column)
|
||||
.map(|boundary| self.gap_width(boundary))
|
||||
.sum::<i64>();
|
||||
@@ -531,7 +538,8 @@ impl Halign {
|
||||
/// Left edge of a column (including all gaps before it).
|
||||
fn column_offset(&self, column: usize) -> i64 {
|
||||
let column = column.min(self.column_widths.len());
|
||||
self.column_widths[..column].iter().sum::<i64>()
|
||||
self.margin
|
||||
+ self.column_widths[..column].iter().sum::<i64>()
|
||||
+ (0..column)
|
||||
.map(|boundary| self.gap_width(boundary))
|
||||
.sum::<i64>()
|
||||
@@ -543,7 +551,7 @@ impl Halign {
|
||||
let start = rule.start.min(last);
|
||||
let end = rule.end.min(last).max(start);
|
||||
let x = self.column_offset(start) + rule.trim_left;
|
||||
let right = (self.column_offset(end + 1) - rule.trim_right).min(self.width);
|
||||
let right = (self.column_offset(end + 1) - rule.trim_right).min(self.width - self.margin);
|
||||
(x, (right - x).max(65_536))
|
||||
}
|
||||
}
|
||||
@@ -1082,6 +1090,7 @@ impl Unit {
|
||||
first_head_len: 0,
|
||||
head_len: 0,
|
||||
foot_len: 0,
|
||||
margin: 0,
|
||||
width,
|
||||
height: 0,
|
||||
line_height,
|
||||
|
||||
@@ -480,8 +480,10 @@ impl Halign {
|
||||
let rule_width = 26_214; // 0.4pt in scaled points.
|
||||
for boundary in &self.vertical_rules {
|
||||
let x = match *boundary {
|
||||
0 => 0,
|
||||
index if index >= self.column_widths.len() => (self.width - rule_width).max(0),
|
||||
0 => self.margin,
|
||||
index if index >= self.column_widths.len() => {
|
||||
(self.width - self.margin - rule_width).max(0)
|
||||
}
|
||||
index => {
|
||||
let left = self.column_offset(index - 1) + self.column_widths[index - 1];
|
||||
let right = self.column_offset(index);
|
||||
|
||||
Reference in new issue
Block a user