summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrés <andmarti@gmail.com>2021-03-26 11:38:24 -0300
committerAndrés <andmarti@gmail.com>2021-03-26 11:38:24 -0300
commite6ec6053a0c0a302be94c32b4cfbc97db81651f0 (patch)
tree2cce36fd18a89a0bd2c92acd6026bd91d020dc6e /src
parentf25d577485fc28d0780574eee4bb7940325dd4fd (diff)
Work on issue #394 (latex export)
Diffstat (limited to 'src')
-rw-r--r--src/file.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/src/file.c b/src/file.c
index 687b943..c4d1c65 100644
--- a/src/file.c
+++ b/src/file.c
@@ -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: