diff options
author | Andrés <andmarti@gmail.com> | 2021-03-26 11:38:24 -0300 |
---|---|---|
committer | Andrés <andmarti@gmail.com> | 2021-03-26 11:38:24 -0300 |
commit | e6ec6053a0c0a302be94c32b4cfbc97db81651f0 (patch) | |
tree | 2cce36fd18a89a0bd2c92acd6026bd91d020dc6e /src | |
parent | f25d577485fc28d0780574eee4bb7940325dd4fd (diff) |
Work on issue #394 (latex export)
Diffstat (limited to 'src')
-rw-r--r-- | src/file.c | 63 |
1 files changed, 34 insertions, 29 deletions
@@ -1467,14 +1467,15 @@ void export_latex(char * fname, int r0, int c0, int rn, int cn, int verbose) { unspecial(f, field, coldelim); } } - if ((s = (*pp)->label)) { - unspecial(f, s, coldelim); - } + if ((s = (*pp)->label)) unspecial(f, s, coldelim); } + if (col < cn) fprintf(f,"%c", coldelim); } + if (row < rn) (void) fprintf (f, "\\\\"); + fprintf(f,"\n"); } - (void) fprintf(f,"\\end{tabular}\n%% ** end of SC-IM spreadsheet output\n"); + fprintf(f,"\\end{tabular}\n%% ** end of SC-IM spreadsheet output\n"); if (fname != NULL) closefile(f, pid, 0); @@ -1482,6 +1483,35 @@ void export_latex(char * fname, int r0, int c0, int rn, int cn, int verbose) { } /** + * \brief TODO Document unspecial() + * + * \details Unspecial (backquotes - > ") things that are special + * chars in a table + * + * \param[in] f file pointer + * \param[in] srt string pointer + * \param[in] delim + * + * \return none + */ +void unspecial(FILE * f, char * str, int delim) { + int backquote = 0; + + if (str_in_str(str, ",") != -1) backquote = 1; + if (backquote) putc('\"', f); + if (*str == '\\') str++; // delete wheeling string operator, OK? + while (*str) { + // for LATEX export + if (delim == '&' && ( (*str == '&') || (*str == '$') || + (*str == '#') || (*str == '%') || (*str == '{') || (*str == '}') || (*str == '&'))) + putc('\\', f); + putc(*str, f); + str++; + } + if (backquote) putc('\"', f); +} + +/** * \brief TODO Document export_delim * * \param[in] fname full path of the file @@ -1559,31 +1589,6 @@ void export_delim(char * fname, char coldelim, int r0, int c0, int rn, int cn, i } /** - * \brief TODO Document unspecial() - * - * \details Unxpecial (backquotes - > ") things that are special - * chars in a table - * - * \param[in] f file pointer - * \param[in] srt string pointer - * \param[in] delim - * - * \return none - */ - -void unspecial(FILE * f, char * str, int delim) { - int backquote = 0; - - if (str_in_str(str, ",") != -1) backquote = 1; - if (backquote) putc('\"', f); - while (*str) { - putc(*str, f); - str++; - } - if (backquote) putc('\"', f); -} - -/** * \brief Check what is the max length of all the lines in a file * * \details Check the maximum length of lines in a file. Note: |