DOKK / manpages / debian 11 / sgf2dg / Games::Go::Sgf2Dg::Dg2TeX.3pm.en
Games::Go::Sgf2Dg::Dg2TeX(3pm) User Contributed Perl Documentation Games::Go::Sgf2Dg::Dg2TeX(3pm)

Games::Go::Sgf2Dg::Dg2TeX - convert Games::Go::Sgf2Dg::Diagrams to TeX

use Games::Go::Sgf2Dg::Dg2TeX

 my $dg2tex = B<Games::Go::Sgf2Dg::Dg2TeX-E<gt>new> (options);
 my $tex = $dg2tex->convertDiagram($diagram);

A Games::Go::Sgf2Dg::Dg2TeX object converts a Games::Go::Sgf2Dg::Diagram object into TeX source code which can be used stand-alone, or it can be incorporated into larger TeX documents.

A new Games::Go::D2TeX takes the following options:

Sets the size of the board.

Default: 19

Numbers on stones are wrapped back to 1 after they reach 100. Numbers associated with comments and diagram titles are not affected.

Default: false

The edges of the board that should be displayed. Any portion of the board that extends beyond these numbers is not included in the output.
This callback defines a subroutine to convert coordinates from $x, $y to whatever coordinates are used in the Games::Go::Sgf2Dg::Diagram object. The default diaCoords converts 1-based $x, $y to the same coordinates used in SGF format files. You only need to define this if you're using a different coordinate system in the Diagram.

Default:
sub { my ($x, $y) = @_;
$x = chr($x - 1 + ord('a')); # convert 1 to 'a', etc
$y = chr($y - 1 + ord('a'));
return("$x$y"); }, # concatenate two letters

See also the diaCoords method below.

If file is defined, the TeX source is dumped into the target. The target can be any of:
The filename will be opened using IO::File->new. The filename should include the '>' or '>>' operator as described in 'perldoc IO::File'. TeX source is written into the file.
A file descriptor as returned by IO::File->new, or a \*FILE descriptor. TeX source is written into the file.
TeX source is concatenated to the end of the string.
TeX source is split on "\n" and each line is pushed onto the array.

Default: undef

A user defined subroutine to replace the default printing method. This callback is called from the print method (below) with the reference to the Dg2TeX object and a list of lines that are part of the TeX diagram source.
This generates very simple TeX which may not look so good on the page, but is convenient if you intend to edit the TeX.

Default: false

This generates a two-column format using smaller fonts. This option forces simple true.

Default: false

Adds coordinates to right and bottom edges.

Default: false

Use fonts magnified 1.2 times.

Default: false

Certain characters, when found in comments, are normally remapped as follows:

    \   =>  $\backslash$
    {   =>  $\lbrace$
    }   =>  $\rbrace$
    $   =>  \$
    &   =>  \&
    #   =>  \#
    ^   =>  $\wedge$
    _   =>  \_
    %   =>  \%
    ~   =>  $\sim$
    <   =>  $<$
    >   =>  $>$
    |   =>  $|$
    

(see the TeX Book page 38). When texComments is specified, the mappings are suppressed so you can embed normal TeX source (like {\bf change fonts}) directly inside the comments.

floatControl is a string that controls which side diagrams floats on. An 'l' puts the diagram on the left side (text on the right), 'r' puts the diagram on the right side, 'a' alternates, and any other character places the diagram randomly. The first character is for the first diagram, second character is for the second diagram, and so on. When there is only one character left, that character controls all remaining diagrams.

floatControl is used only during 'normal' formatting. It is not used with 'simple' or 'twoColumn' formats.

Default: 'rx' # first diagram on the right, all others are random

Default: 12

If twoColumn is true, simple is turned on (no warning).

$dg2tex->configure (option => value, ?...?)
Change Dg2TeX options from values passed at new time.
Provides access to the diaCoords option (see above). Returns coordinates in the converter's coordinate system for board coordinates ($x, $y). For example, to get a specific intersection structure:

    my $int = $diagram->get($dg2mp->diaCoords(3, 4));
    
$dg2tex->print ($tex ? , ... ?)
prints raw TeX code to file as defined at new time. Whether or not file was defined, print accumulates the TeX code for later retrieval with converted.
Returns the TeX source code converted so far for the Dg2TeX object. If $replacement_tex is defined, the accumulated TeX source code is replaced by $replacement_tex.
$dg2tex->comment ($comment ? , ... ?)
Inserts the TeX comment character ('%') in front of each line of each comment and prints it to file.
Converts a Games::Go::Sgf2Dg::Diagram into TeX. If file was defined in the new method, the TeX source is dumped into the file. In any case, the TeX source is returned as a string scalar.
Converts $text into TeX code by changing certain characters that are not available in TeX cmr10 font, and by converting \n\n into \hfil\break. convertText behavior is modified by texComments and simple options.

Returns the converted text.

$dg2tex->close
print the TeX closer (\bye) and close the dg2tex object. Also closes file if appropriate.

sgf2dg(1)">">sgf2dg(1)
Script to convert SGF format files to Go diagrams

Nah. At least, I don't think so. Well, I hope not.

2019-10-27 perl v5.30.0