Games::Go::Sgf2Dg::Dg2TeX(3pm)

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

SYNOPSIS
use Games::Go::Sgf2Dg::Dg2TeX

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

DESCRIPTION
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.

NEW

my $dg2tex = Games::Go::Sgf2Dg::Dg2TeX->new (?options?)

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

boardSizeX => number
boardSizeY => number
    Sets the size of the board.

    Default: 19

doubleDigits => true | false
    Numbers on stones are wrapped back to 1 after they reach 100. Numbers associated with comments and diagram titles are not affected.

    Default: false

topLine     => number (Default: 1)
bottomLine  => number (Default: 19)
leftLine    => number (Default: 1)
rightLine   => number (Default: 19)
    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.

diaCoords => sub { # convert $x, $y to Games::Go::Sgf2Dg::Diagram coordinates }
    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.

file => 'filename' | $descriptor | \$string | \@array
    If file is defined, the TeX source is dumped into the target. The target can be any of:

    filename
        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.

    descriptor
        A file descriptor as returned by IO::File->new, or a \*FILE descriptor. TeX source is written into the file.

    reference to a string scalar
        TeX source is concatenated to the end of the string.

    reference to an array
        TeX source is split on "\n" and each line is pushed onto the array.

    Default: undef

print => sub { my ($dg2tex, @tex) = @_; ... }
    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.

simple => true | false
    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

twoColumn => true | false
    This generates a two-column format using smaller fonts. This option forces simple true.

    Default: false

coords => true | false
    Adds coordinates to right and bottom edges.

    Default: false

bigFonts => true | false
    Use fonts magnified 1.2 times.

    Default: false

texComments => true | 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 => controls which side diagrams will float on
    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

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

METHODS

$dg2tex->configure (option => value, ?...?)
    Change Dg2TeX options from values passed at new time.

my $coord = $dg2mp->diaCoords ($x, $y)
    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.

my $tex = $dg2tex->converted ($replacement_tex)
    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.

my $tex_source = $dg2tex->convertDiagram ($diagram)
    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.

my $tex = $dg2tex->convertText ($text)
    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.

SEE ALSO

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

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