texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: LaTeX.pm: handle @pagesizes


From: Patrice Dumas
Subject: branch master updated: LaTeX.pm: handle @pagesizes
Date: Sat, 21 Aug 2021 16:55:26 -0400

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 3f06aa9  LaTeX.pm: handle @pagesizes
3f06aa9 is described below

commit 3f06aa908c4a1423e75517faa18ba12deef4985a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 21 22:54:03 2021 +0200

    LaTeX.pm: handle @pagesizes
---
 tp/Texinfo/Convert/LaTeX.pm                        | 30 ++++++++-
 tp/t/latex_tests.t                                 | 19 ++++++
 .../latex_tests/pagesizes/res_latex/pagesizes.tex  | 78 ++++++++++++++++++++++
 3 files changed, 124 insertions(+), 3 deletions(-)

diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 00e56d2..3f5a419 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -106,6 +106,18 @@
 # @fonttextsize with \changefontsize does not seems to change fonts much.
 # It seems to change in the text, but only 10pt, and does not seems to
 # change sections font sizes.
+#
+# The @afourpaper, @afourlatex and @afourwide commands all map to
+# papername=a4paper.  It is most likely ok for @afourlatex, but the other
+# two should be associated with other geometries.
+#
+# The \geometry command does not really reset the geometry after
+# \begin{document} according to the documentation, somthing else should
+# be used to switch paper definition.
+#
+# @pagesizes uses \newgeometry which forgets about previous settings except
+# for paper size.  It could be a good thing to change geometry that way,
+# but it is not how Texinfo TeX does it.
 
 package Texinfo::Convert::LaTeX;
 
@@ -2335,9 +2347,21 @@ sub _convert($$)
     } elsif ($informative_commands{$command}) {
       $self->_informative_command($root);
       if ($command eq 'pagesizes') {
-#textwidth=
-#textheight=
-
+        my $pagesize_spec = _convert($self, $root->{'args'}->[0]);
+        my @pagesize_args = split(/\s*,\s*/, $pagesize_spec);
+        print STDERR "".join("|", @pagesize_args)."\n";
+        my @geometry;
+        my $height = shift @pagesize_args;
+        if (defined($height) and $height ne '') {
+          push @geometry, "textheight=$height";
+        }
+        my $width = shift @pagesize_args;
+        if (defined($width) and $width ne '') {
+          push @geometry, "textwidth=$width";
+        }
+        if (scalar(@geometry)) {
+          $result .= "\\newgeometry{".join(',', @geometry)."}\n";
+        }
       } elsif ($command eq 'paragraphindent'
           and $root->{'extra'}->{'misc_args'}->[0]) {
         my $indentation_spec = $root->{'extra'}->{'misc_args'}->[0];
diff --git a/tp/t/latex_tests.t b/tp/t/latex_tests.t
index 0a63109..9a31be6 100644
--- a/tp/t/latex_tests.t
+++ b/tp/t/latex_tests.t
@@ -405,6 +405,25 @@ After afourpaper
 @chapter afourpaper reset
 
 In afourpaper reset
+'],
+['pagesizes',
+'@setfilename pagesizes.info
+
+@pagesizes 200mm,150mm
+
+@node Top
+@top section top
+
+@node chapter
+@chapter Chapter
+
+@pagesizes 11.5in
+
+@chapter other pagesizes
+
+@pagesizes , 130mm
+
+@pagesizes , 
 ']
 );
 
diff --git a/tp/t/results/latex_tests/pagesizes/res_latex/pagesizes.tex 
b/tp/t/results/latex_tests/pagesizes/res_latex/pagesizes.tex
new file mode 100644
index 0000000..ebcd6ac
--- /dev/null
+++ b/tp/t/results/latex_tests/pagesizes/res_latex/pagesizes.tex
@@ -0,0 +1,78 @@
+\documentclass{book}
+\usepackage{makeidx}\makeindex
+\usepackage{amsfonts}
+\usepackage{amsmath}
+\usepackage[gen]{eurosym}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
+\usepackage{graphicx}
+\usepackage{needspace}
+\usepackage{etoolbox}
+\usepackage{fontsize}
+\usepackage{geometry}
+\usepackage{fancyhdr}
+\usepackage{float}
+% use hidelinks to remove boxes around links to be similar with Texinfo TeX
+\usepackage[hidelinks]{hyperref}
+\usepackage[utf8]{inputenc}
+
+% redefine the \mainmatter command such that it does not clear page
+% as if in double page
+\makeatletter
+\renewcommand\mainmatter{\clearpage\@mainmattertrue\pagenumbering{arabic}}
+\makeatother
+
+% command that does nothing used to help with substitutions in commands
+\newcommand{\GNUTexinfoplaceholder}[1]{}
+
+% called when setting single headers
+% use \nouppercase to match with Texinfo TeX style
+\newcommand{\GNUTexinfosetsingleheader}{\pagestyle{fancy}
+\fancyhf{}
+\lhead{\nouppercase{\leftmark}}
+\rhead{\thepage}
+}
+
+% called when setting double headers
+\newcommand{\GNUTexinfosetdoubleheader}[1]{\pagestyle{fancy}
+\fancyhf{}
+\fancyhead[LE,RO]{\thepage}
+\fancyhead[RE]{#1}
+\fancyhead[LO]{\nouppercase{\leftmark}}
+}
+
+% for part and chapter, which call \thispagestyle{plain}
+\fancypagestyle{plain}{ %
+ \fancyhf{}
+ \fancyhead[LE,RO]{\thepage}
+}
+
+% match Texinfo TeX style
+\renewcommand{\headrulewidth}{0pt}%
+
+% avoid pagebreak and headings setting for a sectionning command
+\newcommand{\GNUTexinfonopagebreakheading}[2]{\let\clearpage\relax 
\let\cleardoublepage\relax \let\thispagestyle\GNUTexinfoplaceholder #1{#2}}
+
+
+\renewcommand{\includegraphics}[1]{\fbox{FIG #1}}
+
+% set default for @setchapternewpage
+\makeatletter
+\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{\GNUTexinfoplaceholder{setchapternewpage
 placeholder}\clearpage}{}{}
+\makeatother
+\GNUTexinfosetsingleheader{}%
+
+
+\newgeometry{textheight=200mm,textwidth=150mm}
+
+\begin{document}
+\chapter{Chapter}
+\label{anchor:chapter}%
+
+\newgeometry{textheight=11.5in}
+
+\chapter{other pagesizes}
+
+\newgeometry{textwidth=130mm}
+
+\end{document}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]