Exemple #1
0
        /// <summary>
        /// This method creates a figure.
        /// </summary>
        /// <remarks>A figure environment will be placed somewhere according to position settings.
        /// It is an floating environment.</remarks>
        /// <param name="caption">Text for figure caption.</param>
        /// <param name="groupPlot">GroupPlot settings needed for generation.</param>
        /// <param name="converter">TEX converter.</param>
        internal static string GroupPlotFigure(string caption, GroupPlot groupPlot, ITeXConverter converter)
        {
            var allPlots = new List <PGFPlots.Plot>();

            foreach (var groupedPlot in groupPlot.GroupedPlots)
            {
                allPlots.AddRange(groupedPlot.Plots);
            }

            if (groupPlot.GroupOptions.GroupLegendOptions != null)
            {
                var maxLegendEntry = Enumerable.Max <string>(groupPlot.GroupOptions.GroupLegendOptions.LegendEntries, l => l.Length);

                if (String.IsNullOrEmpty(groupPlot.GroupOptions.GroupLegendOptions.LegendOptions.TextWidth))
                {
                    groupPlot.GroupOptions.GroupLegendOptions.LegendOptions.TextWidth = getLegendWidth(groupPlot.GroupOptions.GroupLegendOptions.LegendOptions.LegendPosition,
                                                                                                       groupPlot.Landscape, maxLegendEntry);
                }
            }

            adjustAxisDimensionForGroupPlots(groupPlot);

            var pictureText = new PlotWriter(groupPlot.Colors, converter).PictureGroupPlot(groupPlot.GroupedPlots,
                                                                                           groupPlot.AxisOptions,
                                                                                           groupPlot.GroupOptions);

            return(plotFigure(caption, groupPlot, pictureText));
        }
        /// <summary>
        ///    This method generates a tabular from a given data view object.
        /// </summary>
        /// <seealso cref="SimpleTable" />
        /// <remarks>
        /// </remarks>
        /// <param name="caption">>Text for table caption.</param>
        /// <param name="label">Text for table lable. Should start with tab:.</param>
        /// <param name="data">Data to be shown in table.</param>
        /// <param name="converter">Converter.</param>
        /// <param name="builderRepository">Repository builder needed to get chunks of tex objects.</param>
        public static string Table(string caption, string label, DataView data, ITeXConverter converter, ITeXBuilderRepository builderRepository)
        {
            if (data.Count == 0)
            {
                return(String.Empty);
            }

            var hasNotes   = HasNotes(data.Table);
            var tableNotes = getTableNotes(data);
            var header     = longTableHeader(data, tableNotes, converter);

            return(createTable(data, converter, builderRepository, hasNotes, header, tableNotes, caption: caption, label: label));
        }
        private static string createTable(DataView data, ITeXConverter converter, ITeXBuilderRepository builderRepository, bool hasNotes, string header, Dictionary <string, char> tableNotes, int spaceNeeded = 6, string caption = null, string label = null)
        {
            var tex = new StringBuilder();

            //if the available space is less than 6 lines the table starts on next page to avoid page breaks for with no lines.
            tex.Append(Helper.Needspace(Helper.BaseLineSkip(spaceNeeded)));
            tex.Append(Helper.Begin(Helper.Environments.center));
            tex.Append(arrayStretch(ARRAY_STRETCH));

            if (hasNotes)
            {
                tex.Append(Helper.Begin(Helper.Environments.ThreePartTable));
            }

            tex.Append(Helper.Begin(Helper.Environments.longtabu));
            tex.AppendFormat(" to {0}\\linewidth", TABLE_WIDTH);
            tex.Append(createColumnDesign(data));

            //Create header
            tex.Append(header);

            // rows
            tex.Append(createRows(data, tableNotes, converter, builderRepository));
            tex.Append(HLine());

            if (caption != null)
            {
                tex.Append(Helper.Caption(caption));
                tex.Append(Helper.Label(label));
                tex.Append(Helper.LineBreak());
            }

            tex.Append(Helper.End(Helper.Environments.longtabu));

            if (caption == null)
            {
                //the longtable package always increases the table counter. If no caption is set that is not wanted.
                tex.Append(decreaseTableCounter());
            }

            if (hasNotes)
            {
                tex.Append(TableWriter.tableNotes(tableNotes, converter));
                tex.Append(Helper.End(Helper.Environments.ThreePartTable));
            }

            tex.Append(Helper.End(Helper.Environments.center));
            return(tex.ToString());
        }
        /// <summary>
        /// This creates all table notes.
        /// </summary>
        /// <param name="tableNotes"></param>
        /// <param name="converter"></param>
        /// <returns></returns>
        private static string tableNotes(Dictionary <string, char> tableNotes, ITeXConverter converter)
        {
            var tex = new StringBuilder();

            tex.Append(Helper.Begin(Helper.Environments.flushleft));
            tex.Append(notesRule());
            tex.Append(Helper.Begin(Helper.Environments.tablenotes));

            foreach (var note in tableNotes)
            {
                tex.Append(tableNote(note.Value, converter.StringToTeX(note.Key)));
            }

            tex.Append(Helper.End(Helper.Environments.tablenotes));
            tex.Append(Helper.End(Helper.Environments.flushleft));
            return(tex.ToString());
        }
Exemple #5
0
 protected override void Context()
 {
     _converter = DefaultConverter.Instance;
     sut        = new ReportSettings
     {
         Title           = "A GREAT TITLE",
         SubTitle        = "A great report",
         Author          = "ZTMSE",
         Keywords        = new [] { "TEST" },
         Software        = "SBSuite",
         SoftwareVersion = "2.5",
         ContentFileName = "myContent",
         ColorStyle      = ReportSettings.ReportColorStyles.BlackAndWhite,
         TemplateFolder  = ConstantsForSpecs.StandardTemplateFolder
     };
     _workingTex = FileHelper.GenerateTemporaryFileName() + ".tex";
     File.Copy(sut.TemplateFullPath, _workingTex);
 }
Exemple #6
0
        /// <summary>
        /// This method creates a figure for a bar plot.
        /// </summary>
        /// <remarks>A figure environment will be placed somewhere according to position settings.
        /// It is an floating environment.</remarks>
        /// <param name="caption">Text for figure caption.</param>
        /// <param name="plot">Plot settings needed for generation.</param>
        /// <param name="converter">TEX converter.</param>
        internal static string BarPlotFigure(string caption, BarPlot plot, ITeXConverter converter)
        {
            var isLegendBeside = plot.AxisOptions.LegendOptions != null && getIsLegendBeside(plot.AxisOptions.LegendOptions.LegendPosition);

            adjustAxisDimensionForFigures(plot.AxisOptions, plot.Landscape, isLegendBeside, 90, 60);

            var maxLegendEntry = getMaxLegendEntryLength(plot.Plots);

            if (plot.AxisOptions.LegendOptions != null)
            {
                if (String.IsNullOrEmpty(plot.AxisOptions.LegendOptions.TextWidth))
                {
                    plot.AxisOptions.LegendOptions.TextWidth = getLegendWidth(plot.AxisOptions.LegendOptions.LegendPosition,
                                                                              plot.Landscape, maxLegendEntry);
                }
            }

            var pictureText = new PlotWriter(plot.Colors, converter).Picture(plot.BarPlotOptions, plot.AxisOptions, plot.Plots);

            return(plotFigure(caption, plot, pictureText));
        }
 public AxisOptions(ITeXConverter converter)
 {
     _converter = converter;
 }
        private static string createChildTable(DataView childView, Dictionary <string, char> tableNotes, DataRelation relation, ITeXConverter converter, ITeXBuilderRepository builderRepository, ref int?level)
        {
            var childTable = new StringBuilder();

            if (level == null)
            {
                level = 1;
            }

            childTable.Append(Helper.Begin(Helper.Environments.tabu));
            level++;
            childTable.AppendFormat(" to {0}\\linewidth ", Math.Pow(TABLE_WIDTH, (double)level));
            childTable.Append(createColumnDesign(childView, relation));

            var childHeader = new StringBuilder();

            childHeader.Append(header(childView, tableNotes, converter, relation));
            var columnsCount = childView.Table.Columns.Cast <DataColumn>().Count(col => !col.IsHidden() && !relation.ChildColumns.Contains(col));

            childHeader.Append(CLine(1, columnsCount));
            childTable.Append(childHeader);

            childTable.Append(createRows(childView, tableNotes, converter, builderRepository, relation, level));
            childTable.Append(CLine(1, columnsCount));
            childTable.Append(Helper.End(Helper.Environments.tabu));
            level--;

            return(childTable.ToString());
        }
        private static string createRow(DataRowView row, Dictionary <string, char> tableNotes, ITeXConverter converter, ITeXBuilderRepository builderRepository, DataRelation relation = null, int?level = null)
        {
            var rowLine = new StringBuilder();

            rowLine.Append(setPagebreakDesirability(getPagebreakDesirability(row, level)));

            var columnsCount = 0;

            foreach (DataColumn col in row.DataView.Table.Columns)
            {
                if (col.IsHidden())
                {
                    continue;
                }
                if (relation != null)
                {
                    if (relation.ChildColumns.Contains(col))
                    {
                        continue;
                    }
                }
                columnsCount++;
                if (columnsCount > 1)
                {
                    rowLine.AppendFormat(" {0} ", VALUE_SEPARATOR);
                }
                var colValue = row[col.ColumnName];
                if (colValue == null || colValue == DBNull.Value)
                {
                    continue;
                }
                // datatype specifics
                string value;
                if (col.DataType == typeof(double) || col.DataType == typeof(float))
                {
                    value = converter.StringToTeX(_numericFormatter.Format(Convert.ToDouble(colValue)));
                }
                else if (col.DataType == typeof(DateTime))
                {
                    value = converter.StringToTeX(((DateTime)colValue).ToShortTimeString());
                }
                else if (col.DataType == typeof(Text))
                {
                    value = builderRepository.ChunkFor(colValue);
                }
                else
                {
                    value = converter.StringToTeX(colValue.ToString());
                }
                rowLine.Append(value);
            }
            rowLine.Append(Helper.LineBreak());
            rowLine.Append(phantomline());
            var first = true;

            foreach (DataRelation childrelation in row.DataView.Table.ChildRelations)
            {
                var childView = row.CreateChildView(childrelation);
                if (childView.Count == 0)
                {
                    continue;
                }
                if (first)
                {
                    rowLine.Append(CLine(1, columnsCount));
                    first = false;
                }

                rowLine.Append(multiFirstColumn(columnsCount, ColumnAlignments.c,
                                                createChildTable(childView, tableNotes, childrelation, converter, builderRepository, ref level)));
                rowLine.Append(Helper.LineBreak());
                rowLine.Append(phantomline());
            }
            if (row.DataView.Table.ChildRelations.Count > 0)
            {
                rowLine.Append(CLine(1, columnsCount));
            }

            return(rowLine.ToString());
        }
        private static string createRows(DataView data, Dictionary <string, char> tableNotes, ITeXConverter converter, ITeXBuilderRepository builderRepository, DataRelation relation = null, int?level = null)
        {
            var tex = new StringBuilder();

            foreach (DataRowView row in data)
            {
                tex.Append(createRow(row, tableNotes, converter, builderRepository, relation, level));
            }
            tex.Append(phantomline());
            return(tex.ToString());
        }
Exemple #11
0
 /// <summary>
 ///    This method creates a tex chunk for a structure element with a special toctitle.
 /// </summary>
 /// <param name="element">>Structur element.</param>
 /// <param name="name">Name of structure element.</param>
 /// <param name="converter">TEX converter</param>
 /// <param name="toctitle">Name of the structure element used in table of contents. Shorter version of name.</param>
 /// <returns>TEX chunk.</returns>
 internal static string CreateStructureElement(StructureElements element, string name, ITeXConverter converter, string toctitle)
 {
     return($"\\{element}[{converter.StringToTeX(toctitle)}]{{{converter.StringToTeX(name)}}}\n");
 }
 public PlotWriter(IEnumerable <Color> colors, ITeXConverter converter)
 {
     _colors    = colors;
     _converter = converter;
 }
Exemple #13
0
        /// <summary>
        /// This method creates a figure.
        /// </summary>
        /// <remarks>A figure environment will be placed somewhere according to position settings.
        /// It is an floating environment.</remarks>
        /// <param name="caption">Text for figure caption.</param>
        /// <param name="plot">Plot settings needed for generation.</param>
        /// <param name="converter">TEX converter.</param>
        internal static string PlotThreeOrdinatesFigure(string caption, PlotThreeOrdinates plot, ITeXConverter converter)
        {
            var isLegendBeside = getIsLegendBeside(plot.AxisOptionsY3.LegendOptions.LegendPosition);
            var maxLegendEntry = getMaxLegendEntryLength(plot.Plots.Concat <Plot>(plot.PlotsY2).Concat <Plot>(plot.PlotsY3));

            adjustAxisDimensionForFigures(plot.AxisOptions, plot.Landscape, isLegendBeside, 90, 40, 70);
            adjustAxisDimensionForFigures(plot.AxisOptionsY2, plot.Landscape, isLegendBeside, 90, 40, 70);
            adjustAxisDimensionForFigures(plot.AxisOptionsY3, plot.Landscape, isLegendBeside, 90, 40, 70);

            if (String.IsNullOrEmpty(plot.AxisOptionsY3.LegendOptions.TextWidth))
            {
                plot.AxisOptionsY3.LegendOptions.TextWidth = getLegendWidth(
                    plot.AxisOptionsY3.LegendOptions.LegendPosition, plot.Landscape, maxLegendEntry);
            }

            var pictureText = new PlotWriter(plot.Colors, converter).PictureThreeOrdinates(plot.AxisOptions,
                                                                                           plot.AxisOptionsY2,
                                                                                           plot.AxisOptionsY3,
                                                                                           plot.Plots,
                                                                                           plot.PlotsY2,
                                                                                           plot.PlotsY3);

            return(plotFigure(caption, plot, pictureText));
        }
        private static string longTableHeader(DataView data, Dictionary <string, char> tableNotes, ITeXConverter converter)
        {
            const string END_HEAD       = "\\endhead\n";
            const string END_FIRST_HEAD = "\\endfirsthead\n";
            const string END_FOOT       = "\\endfoot\n";
            const string END_LAST_FOOT  = "\\endlastfoot\n";

            var header       = TableWriter.header(data, tableNotes, converter);
            var shownColumns = data.Table.Columns.Cast <DataColumn>().Count(col => !col.IsHidden());

            var tex = new StringBuilder();

            //table header for all continued pages
            tex.Append(HLine());
            tex.Append(multiFirstColumn(shownColumns, ColumnAlignments.l, "\\small\\sl continued from previous page"));
            tex.Append(Helper.LineBreak());
            tex.Append(HLine());
            tex.Append(header);
            tex.Append(HLine());
            tex.Append(END_HEAD);

            //table header
            tex.Append(HLine());
            tex.Append(header);
            tex.Append(HLine());
            tex.Append(END_FIRST_HEAD);

            //table tail
            tex.Append(HLine());
            tex.Append(multiFirstColumn(shownColumns, ColumnAlignments.r, "\\small\\sl continued on next page"));
            tex.Append(Helper.LineBreak());
            tex.Append(HLine());
            tex.Append(END_FOOT);

            //table last tail
            tex.Append(END_LAST_FOOT);

            return(tex.ToString());
        }
        /// <summary>
        ///    This method creates a nicer header for pivot tables.
        /// </summary>
        /// <param name="pivotData">Data view containing data to pivot.</param>
        /// <param name="tableNotes">Notes of table.</param>
        /// <param name="pivotInfo">Information specifying the pivotation.</param>
        /// <param name="texTranslations">Use defined tex string for naming aggregations within the tex header.</param>
        /// <param name="converter">Tex converter.</param>
        /// <returns>TEX chunk.</returns>
        private static string headerForPivot(DataView pivotData, Dictionary <string, char> tableNotes, PivotInfo pivotInfo, Cache <Aggregate, string> texTranslations, ITeXConverter converter)
        {
            var colFieldNames = pivotInfo.ColumnFields;
            var colValueList  = pivotData.ToTable(true, colFieldNames.ToArray()).AsEnumerable().ToList();

            var header     = new StringBuilder();
            var headerRow  = new StringBuilder();
            var multiplied = pivotInfo.ColumnFields.Count;

            header.Append(HLine());
            for (int i = 0; i < colFieldNames.Count; i++)
            {
                var fieldName  = colFieldNames[i];
                var columnName = $"{{{converter.StringToTeX(fieldName)}}}";
                if (pivotData.Table.Columns.Contains(fieldName))
                {
                    columnName += TNote(pivotData.Table.Columns[fieldName], tableNotes);
                    var unit = pivotData.Table.Columns[fieldName].GetUnit();
                    if (!String.IsNullOrEmpty(unit))
                    {
                        columnName = $"{columnName} [{converter.StringToTeX(unit)}]";
                    }
                }
                if (headerRow.Length > 0)
                {
                    headerRow.Append(multiColumn(pivotInfo.RowFields.Count, ColumnAlignments.r,
                                                 Helper.Bold(columnName)));
                }
                else
                {
                    headerRow.Append(multiFirstColumn(pivotInfo.RowFields.Count, ColumnAlignments.r,
                                                      Helper.Bold(columnName)));
                }
                for (int index = 0; index < colValueList.Count; index++)
                {
                    var colValue  = colValueList[index];
                    var value     = colValue[fieldName].ToString();
                    var multiples = 0;
                    while (multiples < multiplied && (index + multiples + 1) < colValueList.Count &&
                           value == colValueList[index + multiples + 1][fieldName].ToString())
                    {
                        multiples++;
                    }
                    multiplied = multiples;
                    index     += multiples;
                    headerRow.Append(VALUE_SEPARATOR);
                    headerRow.Append(multiColumn(pivotInfo.Aggregates.Count() * pivotInfo.DataFields.Count * (multiples + 1), ColumnAlignments.c,
                                                 converter.StringToTeX(colValue[fieldName].ToString())));
                }

                headerRow.Append(Helper.LineBreak());
                headerRow.Append(HLine());
                header.Append(headerRow);
                headerRow = new StringBuilder();
            }

            headerRow = new StringBuilder();
            foreach (var rowField in pivotInfo.RowFields)
            {
                if (headerRow.Length > 0)
                {
                    headerRow.Append(VALUE_SEPARATOR);
                }
                headerRow.Append(Helper.Bold(converter.StringToTeX(rowField)));
                if (pivotData.Table.Columns.Contains(rowField))
                {
                    headerRow.Append(Helper.Bold(TNote(pivotData.Table.Columns[rowField], tableNotes)));
                    var unit = pivotData.Table.Columns[rowField].GetUnit();
                    if (!String.IsNullOrEmpty(unit))
                    {
                        headerRow.AppendFormat(" [{0}]", converter.StringToTeX(unit));
                    }
                }
            }
            foreach (var colValue in colValueList)
            {
                foreach (var aggregate in pivotInfo.Aggregates)
                {
                    foreach (var datafield in pivotInfo.DataFields)
                    {
                        headerRow.Append(VALUE_SEPARATOR);
                        if (aggregate != null)
                        {
                            var funcName = texTranslations.Contains(aggregate) ? texTranslations[aggregate] : aggregate.Name;
                            headerRow.Append(Helper.Bold(funcName));
                            if (aggregate.DataType == typeof(bool) || aggregate.DataType == typeof(int))
                            {
                                continue;
                            }
                        }
                        if (pivotInfo.DataFields.Count > 1)
                        {
                            var datafieldName = converter.StringToTeX(datafield);
                            datafieldName += TNote(pivotData.Table.Columns[datafield], tableNotes);
                            headerRow.Append(Helper.Bold($"({datafieldName})"));
                        }
                        if (pivotData.Table.Columns.Contains(datafield))
                        {
                            var unit = pivotData.Table.Columns[datafield].GetUnit();
                            if (!String.IsNullOrEmpty(unit))
                            {
                                headerRow.Append(Helper.Bold($" [{converter.StringToTeX(unit)}]"));
                            }
                        }
                    }
                }
            }
            headerRow.Append(Helper.LineBreak());
            header.Append(headerRow);
            header.Append(HLine());

            return(header.ToString());
        }
        /// <summary>
        ///    This method creates a header for tables.
        /// </summary>
        /// <param name="data">Data view containing data.</param>
        /// <param name="tableNotes">Notes of the table.</param>
        /// <param name="converter">Tex converter.</param>
        /// <param name="relation"></param>
        /// <returns>TEX chunk.</returns>
        private static string header(DataView data, Dictionary <string, char> tableNotes, ITeXConverter converter, DataRelation relation = null)
        {
            // create standard header
            var header = new StringBuilder();

            header.Append("\\rowfont[c]{\\bfseries}\n");
            var newHeader = true;

            foreach (DataColumn col in data.Table.Columns)
            {
                if (col.IsHidden())
                {
                    continue;
                }
                if (relation != null)
                {
                    if (relation.ChildColumns.Contains(col))
                    {
                        continue;
                    }
                }
                if (newHeader)
                {
                    header.AppendFormat("{{{0}}}", converter.StringToTeX(col.Caption));
                    newHeader = false;
                }
                else
                {
                    header.AppendFormat(" {0} {{{1}}}", VALUE_SEPARATOR, converter.StringToTeX(col.Caption));
                }

                header.Append(TNote(col, tableNotes));
                var unit = col.GetUnit();
                if (!String.IsNullOrEmpty(unit))
                {
                    header.AppendFormat(" [{0}]", converter.StringToTeX(unit));
                }
            }
            header.Append(Helper.LineBreak());
            return(header.ToString());
        }
Exemple #17
0
 protected BaseItem()
 {
     Converter = DefaultConverter.Instance;
 }
Exemple #18
0
 /// <summary>
 ///    This methods creates a footnote.
 /// </summary>
 /// <remarks>Footnotes unfortunately don't work with tables, as it is considered a bad practice.</remarks>
 /// <param name="footnote">Text for the footnote.</param>
 /// <param name="converter">Indicates whether texts should be converted or not.</param>
 /// <returns>TEX chunk.</returns>
 public static string Footnote(string footnote, ITeXConverter converter)
 {
     return($"\\footnote{{{converter.StringToTeX(footnote)}}}");
 }
Exemple #19
0
 internal static string InlineGraphic(string fileName, ITeXConverter converter)
 {
     return(includeGraphics($"height={Helper.BaseLineSkip(1)}", fileName, converter));
 }
 public GroupOptions(ITeXConverter converter)
 {
     _converter = converter;
 }
Exemple #21
0
 /// <summary>
 /// This method creates TEX chunk for inclusion of images.
 /// </summary>
 /// <param name="options">To specify scale, height or width parameters.</param>
 /// <param name="fileName">Filename of image to include.</param>
 /// <param name="converter">TEX converter.</param>
 /// <returns>TEX chunk.</returns>
 private static string includeGraphics(string options, string fileName, ITeXConverter converter)
 {
     return($"\\includegraphics[{options}]{{{converter.FilePathToTeX(fileName)}}}\n");
 }
        /// <summary>
        ///    This method generates a tabular from a given data view object.
        /// </summary>
        /// <seealso cref="SimpleTable" />
        /// <remarks>
        /// </remarks>
        /// <param name="caption">>Text for table caption.</param>
        /// <param name="label">Text for table lable. Should start with tab:.</param>
        /// <param name="data">Data to be shown in table.</param>
        /// <param name="pivotInfo">Information about pivotation.</param>
        /// <param name="texTranslations">For used aggregations a tex conform string can be set.</param>
        /// <param name="converter">Converter.</param>
        /// <param name="builderRepository">Repository builder needed to get chunks of tex objects.</param>
        /// <param name="rawData">Data which has been pivoted.</param>
        public static string PivotTable(string caption, string label, DataView data, DataTable rawData, PivotInfo pivotInfo, Cache <Aggregate, string> texTranslations, ITeXConverter converter, ITeXBuilderRepository builderRepository)
        {
            if (data.Count == 0)
            {
                return(String.Empty);
            }

            var tableNotes = getTableNotes(rawData, pivotInfo);
            var hasNotes   = tableNotes.Any();
            var header     = headerForPivot(rawData.DefaultView, tableNotes, pivotInfo, texTranslations, converter);

            return(createTable(data, converter, builderRepository, hasNotes, header, tableNotes, spaceNeeded: 12, caption: caption, label: label));
        }
Exemple #23
0
        /// <summary>
        /// This method appends the inclusion of a figure.
        /// </summary>
        /// <remarks>A figure environment will be placed somewhere according to position settings.
        /// It is an floating environment.</remarks>
        /// <param name="position">>Where should the figure be placed.</param>
        /// <param name="caption">Text for figure caption.</param>
        /// <param name="label">Text for figure lable. Should start with fig:.</param>
        /// <param name="fileName">Relative path of graphic file to include.</param>
        /// <param name="landscape">Indicates whether the figure is in landscape environment or not.</param>
        /// <param name="converter">TEX converter.</param>
        internal static string IncludeFigure(FigurePositions position, string caption, string label, string fileName, bool landscape, ITeXConverter converter)
        {
            var tex = new StringBuilder();

            tex.Append(Helper.Begin(Helper.Environments.figure));
            tex.AppendFormat("[{0}]\n", position);
            tex.Append(Helper.NoIndent());
            tex.Append(Helper.Centering());

            var options = landscape
                          ? $"max height={Helper.GetLengthInPercentageOfTextWidth(90)}, max width={Helper.GetLengthInPercentageOfTextHeight(100)}"
            : $"max height={Helper.GetLengthInPercentageOfTextHeight(90)}, max width={Helper.GetLengthInPercentageOfTextWidth(100)}";

            options += ", keepaspectratio";
            tex.Append(includeGraphics(options, fileName, converter));

            tex.Append(Helper.Caption(caption));
            tex.Append(Helper.Label(label));
            tex.Append(Helper.End(Helper.Environments.figure));
            return(tex.ToString());
        }
Exemple #24
0
 /// <summary>
 ///    This method creates a tex chunk for a structure element without a special toctitle.
 /// </summary>
 /// <param name="element">Structur element.</param>
 /// <param name="name">Name of structure element.</param>
 /// <param name="converter">TEX converter</param>
 /// <param name="addToToc">Indicates whether the structure should be nummered and added to table of contents.</param>
 /// <returns>TEX chunk.</returns>
 internal static string CreateStructureElement(StructureElements element, string name, ITeXConverter converter, bool addToToc)
 {
     return($"\\{element}{(addToToc ? String.Empty : NO_TOC_SYMBOL)}{{{converter.StringToTeX(name)}}}\n");
 }