[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_convert, _latex_h
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_convert, _latex_header): implement @multitable. |
Date: |
Wed, 19 Jan 2022 17:05:17 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 66729114f1 * tp/Texinfo/Convert/LaTeX.pm (_convert, _latex_header):
implement @multitable.
66729114f1 is described below
commit 66729114f1b1d1e316aa6c7e76b695a5f8b44eb0
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Jan 19 23:05:04 2022 +0100
* tp/Texinfo/Convert/LaTeX.pm (_convert, _latex_header): implement
@multitable.
---
ChangeLog | 5 ++
tp/Texinfo/Convert/LaTeX.pm | 51 +++++++++++++--
.../res_parser/formatting_latex/formatting.tex | 76 +++++++++++++++-------
3 files changed, 100 insertions(+), 32 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3abc343c10..8a762dcd6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-01-19 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/LaTeX.pm (_convert, _latex_header): implement
+ @multitable.
+
2022-01-18 Patrice Dumas <pertusus@free.fr>
* tp/texi2any.pl ($makeinfo_help): in the help block where
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 42452e18dc..503178f586 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -19,8 +19,6 @@
#
# Use texinfo.cnf? Here? in texi2any.pl?
#
-# @multitable not implemented
-#
# @def* not implemented
#
# @shortcontent is not implemented. Tried shorttoc package but it
@@ -1232,6 +1230,9 @@ roundcorner=10pt}
}
$header .= '\usepackage{etoolbox}
';
+ if ($self->{'packages'}->{'array'}) {
+ $header .= "\\usepackage{array}\n";
+ }
if ($self->{'packages'}->{'mdframed'}) {
$header .= "\\usepackage{mdframed}\n";
}
@@ -2737,15 +2738,33 @@ sub _convert($$)
$result .= $self->_convert($prepended);
}
} elsif ($cmdname eq 'multitable') {
- my $columnsize;
+ # for m{} in tabular header
+ $self->{'packages'}->{'array'} = 1;
+ $result .= '\begin{tabular}{';
+ my @fractions;
if ($element->{'extra'}->{'columnfractions'}) {
+ @fractions
+ = @{$element->{'extra'}->{'columnfractions'}->{'extra'}->{'misc_args'}};
} elsif ($element->{'extra'}->{'prototypes'}) {
+ my @prototypes_length;
+ my $total_length = 0.;
foreach my $prototype (@{$element->{'extra'}->{'prototypes'}}) {
- my ($formatted_prototype) = $self->_convert($prototype);
- push @$columnsize,
-
2+Texinfo::Convert::Unicode::string_width($formatted_prototype);
+ # not clear what to do here. For now use the text width
+ my $prototype_text
+ = Texinfo::Convert::Text::convert_to_text($prototype,
+
{Texinfo::Convert::Text::copy_options_for_convert_text($self)});
+ my $length =
Texinfo::Convert::Unicode::string_width($prototype_text);
+ $total_length += $length;
+ push @prototypes_length, $length;
+ }
+ if ($total_length > 0.) {
+ foreach my $length (@prototypes_length) {
+ push @fractions, $length / $total_length;
+ }
}
}
+ $result .= join(' ', map {'m{'.$_.'\textwidth}'} @fractions);
+ $result .= "}%\n";
} elsif ($cmdname eq 'float') {
my $normalized_float_type = '';
if ($element->{'extra'}->{'type'}) {
@@ -3340,7 +3359,12 @@ sub _convert($$)
}
}
} elsif ($type eq 'row') {
- # ...
+ chomp($result);
+ # can happen with diverse added @-command, in particular index commands
+ if ($result =~ /%$/) {
+ $result .= "\n";
+ }
+ $result .= '\\\\'."\n";
} elsif ($type eq $latex_document_type) {
# type marking the beginning of content
$result .= _begin_document($self);
@@ -3392,6 +3416,8 @@ sub _convert($$)
}
}
$self->{'formatting_context'}->[-1]->{'in_quotation'} -= 1;
+ } elsif ($cmdname eq 'multitable') {
+ $result .= '\end{tabular}%'."\n";
}
# close the contexts and register the cells
@@ -3408,6 +3434,17 @@ sub _convert($$)
}
my $old_math_style = pop
@{$self->{'formatting_context'}->[-1]->{'math_style'}};
die if ($old_math_style ne 'one-line');
+ } elsif ($element->{'parent'}->{'type'}
+ and $element->{'parent'}->{'type'} eq 'row') {
+ my $cell_nr = $element->{'extra'}->{'cell_number'};
+ my $multitable = $element->{'parent'}->{'parent'}->{'parent'};
+ my $max_columns = $multitable->{'extra'}->{'max_columns'};
+ my $add_eol = 0;
+ $add_eol = 1 if (chomp($result));
+ if ($cell_nr < $max_columns) {
+ $result .= '&';
+ }
+ $result .= "\n" if ($add_eol);
}
}
diff --git a/tp/tests/layout/res_parser/formatting_latex/formatting.tex
b/tp/tests/layout/res_parser/formatting_latex/formatting.tex
index 9231760534..853931b824 100644
--- a/tp/tests/layout/res_parser/formatting_latex/formatting.tex
+++ b/tp/tests/layout/res_parser/formatting_latex/formatting.tex
@@ -8,6 +8,7 @@
\usepackage{graphicx}
\usepackage{needspace}
\usepackage{etoolbox}
+\usepackage{array}
\usepackage{mdframed}
\usepackage{enumitem}
\usepackage{titleps}
@@ -567,13 +568,18 @@ i--tem 1
\item second c
\end{enumerate}
-mu--ltitable headitem another tab
-mu--ltitable item multitable tab
-mu--ltitable item 2 multitable tab 2
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+mu--ltitable headitem &another tab\\
+mu--ltitable item &multitable tab\\
+mu--ltitable item 2 &multitable tab 2
\index[cp]{index entry within multitable}%
-lone mu--ltitable item
+\\
+lone mu--ltitable item&\\
+\end{tabular}%
-truc bidule
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+truc &bidule\\
+\end{tabular}%
\par\begingroup\obeylines\obeyspaces\frenchspacing\leftskip=2em\relax\parskip=0pt\relax\ttfamily{}%
e{-}{-}xample some
@@ -1746,13 +1752,18 @@ i--tem 1
\item second c
\end{enumerate}
-mu--ltitable headitem another tab
-mu--ltitable item multitable tab
-mu--ltitable item 2 multitable tab 2
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+mu--ltitable headitem &another tab\\
+mu--ltitable item &multitable tab\\
+mu--ltitable item 2 &multitable tab 2
\index[cp]{index entry within multitable}%
-lone mu--ltitable item
+\\
+lone mu--ltitable item&\\
+\end{tabular}%
-truc bidule
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+truc &bidule\\
+\end{tabular}%
\par\begingroup\obeylines\obeyspaces\frenchspacing\leftskip=2em\relax\parskip=0pt\relax\ttfamily{}%
e{-}{-}xample some
@@ -2945,13 +2956,18 @@ i--tem 1
\item second c
\end{enumerate}
-mu--ltitable headitem another tab
-mu--ltitable item multitable tab
-mu--ltitable item 2 multitable tab 2
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+mu--ltitable headitem &another tab\\
+mu--ltitable item &multitable tab\\
+mu--ltitable item 2 &multitable tab 2
\index[cp]{index entry within multitable}%
-lone mu--ltitable item
+\\
+lone mu--ltitable item&\\
+\end{tabular}%
-truc bidule
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+truc &bidule\\
+\end{tabular}%
\par\begingroup\obeylines\obeyspaces\frenchspacing\leftskip=2em\relax\parskip=0pt\relax\ttfamily{}%
e{-}{-}xample some
@@ -4123,13 +4139,18 @@ i--tem 1
\item second c
\end{enumerate}
-mu--ltitable headitem another tab
-mu--ltitable item multitable tab
-mu--ltitable item 2 multitable tab 2
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+mu--ltitable headitem &another tab\\
+mu--ltitable item &multitable tab\\
+mu--ltitable item 2 &multitable tab 2
\index[cp]{index entry within multitable}%
-lone mu--ltitable item
+\\
+lone mu--ltitable item&\\
+\end{tabular}%
-truc bidule
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+truc &bidule\\
+\end{tabular}%
\par\begingroup\obeylines\obeyspaces\frenchspacing\leftskip=2em\relax\parskip=0pt\relax\ttfamily{}%
e{-}{-}xample some
@@ -5312,13 +5333,18 @@ i{-}{-}tem 1
\item second c
\end{enumerate}
-mu{-}{-}ltitable headitem another tab
-mu{-}{-}ltitable item multitable tab
-mu{-}{-}ltitable item 2 multitable tab 2
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+mu{-}{-}ltitable headitem &another tab\\
+mu{-}{-}ltitable item &multitable tab\\
+mu{-}{-}ltitable item 2 &multitable tab 2
\index[cp]{index entry within multitable}%
-lone mu{-}{-}ltitable item
+\\
+lone mu{-}{-}ltitable item&\\
+\end{tabular}%
-truc bidule
+\begin{tabular}{m{0.4\textwidth} m{0.6\textwidth}}%
+truc &bidule\\
+\end{tabular}%
\par\begingroup\obeylines\obeyspaces\frenchspacing\leftskip=2em\relax\parskip=0pt\relax\ttfamily{}%
e{-}{-}xample some
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_convert, _latex_header): implement @multitable.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/texi2any.pl ($makeinfo_help): in the help block where --latex was added. Avoid \n in translated strings, split each option in a translatable string. Report from Benno Schulenberg.
- Next by Date:
branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_open_preformatted) (_close_preformatted, _open_preformatted_command) (_close_preformatted_command, _open_preformatted_stack) (_close_preformatted_command, _convert): format preformatted type as preformatted, not preformatted commands. Preformatted commands only set up 'preformatted_context'.
- Previous by thread:
branch master updated: * tp/texi2any.pl ($makeinfo_help): in the help block where --latex was added. Avoid \n in translated strings, split each option in a translatable string. Report from Benno Schulenberg.
- Next by thread:
branch master updated: * tp/Texinfo/Convert/LaTeX.pm (_open_preformatted) (_close_preformatted, _open_preformatted_command) (_close_preformatted_command, _open_preformatted_stack) (_close_preformatted_command, _convert): format preformatted type as preformatted, not preformatted commands. Preformatted commands only set up 'preformatted_context'.
- Index(es):