comparison scripts/miscellaneous/private/__publish_latex_output__.m @ 30379:363fb10055df stable

maint: Style check m-files ahead of 7.1 release. * Map.m, integral3.m, logspace.m, quad2d.m, quadgk.m, quadl.m, tsearchn.m, get_first_help_sentence.m, print_usage.m, getframe.m, imformats.m, javaclasspath.m, condest.m, null.m, ordeig.m, inputParser.m, license.m, memory.m, methods.m, __publish_html_output__.m, __publish_latex_output__.m, publish.m, ode15s.m, fminbnd.m, fzero.m, configure_make.m, get_description.m, get_forge_pkg.m, annotation.m, camlookat.m, legend.m, __gnuplot_legend__.m, bar.m, colorbar.m, fill3.m, isosurface.m, plotyy.m, polar.m, __bar__.m, __ezplot__.m, __patch__.m, __pie__.m, __plt__.m, __scatter__.m, smooth3.m, stemleaf.m, __gnuplot_drawnow__.m, print.m, printd.m, __add_default_menu__.m, __gnuplot_draw_axes__.m, __gnuplot_print__.m, __print_parse_opts__.m, struct2hdl.m, profexport.m, profile.m, movfun.m, sprandsym.m, betaincinv.m, factor.m, nchoosek.m, gallery.m, hadamard.m, iqr.m, ranks.m, __run_test_suite__.m, test.m, datevec.m, weboptions.m: Style check m-files ahead of 7.1 release.
author Rik <rik@octave.org>
date Fri, 26 Nov 2021 20:53:22 -0800
parents 33d895260fa4
children 796f54d4ddbf
comparison
equal deleted inserted replaced
30377:26f2daafa270 30379:363fb10055df
113 function outstr = do_output_file_extension () 113 function outstr = do_output_file_extension ()
114 outstr = ".tex"; 114 outstr = ".tex";
115 endfunction 115 endfunction
116 116
117 function outstr = do_header (title_str, intro_str, toc_cstr) 117 function outstr = do_header (title_str, intro_str, toc_cstr)
118
118 publish_comment = sprintf ("%s\n", 119 publish_comment = sprintf ("%s\n",
119 "", 120 "",
120 "", 121 "",
121 "% This document was generated by the publish-function", 122 "% This document was generated by the publish-function",
122 ["% from GNU Octave " version()], 123 ["% from GNU Octave " version()],
135 '\usepackage{titlesec}', 136 '\usepackage{titlesec}',
136 '\usepackage[utf8]{inputenc}', 137 '\usepackage[utf8]{inputenc}',
137 '\usepackage[T1]{fontenc}', 138 '\usepackage[T1]{fontenc}',
138 '\usepackage{lmodern}'); 139 '\usepackage{lmodern}');
139 140
140 # "lstlisting" doesn't support multi-byte UTF-8 characters. 141 ## "lstlisting" doesn't support multi-byte UTF-8 characters.
141 # Add substitution rules for some characters (commonly used in languages with 142 ## Add substitution rules for some characters (commonly used in languages with
142 # Latin-based script). 143 ## Latin-based script).
143 # Set of substitions taken from: 144 ## Set of substitions taken from:
144 # https://en.wikibooks.org/w/index.php?title=LaTeX/Source_Code_Listings&oldid=3815132#Encoding_issue 145 ## https://en.wikibooks.org/w/index.php?title=LaTeX/Source_Code_Listings&oldid=3815132#Encoding_issue
145 # FIXME: Any multi-byte UTF-8 character in a non-section comment without a 146 ## FIXME: Any multi-byte UTF-8 character in a non-section comment without a
146 # substitution rule will still cause an error. This should be fixed 147 ## substitution rule will still cause an error. This should be fixed
147 # more generally, or a way how to work around this limitation should 148 ## more generally, or a way how to work around this limitation should
148 # be documented. 149 ## be documented.
149 listings_option = sprintf ("%s\n", 150 listings_option = sprintf ("%s\n",
150 "", 151 "",
151 "", 152 "",
152 '\lstset{', 153 '\lstset{',
153 'language=Octave,', 154 'language=Octave,',
234 str, 235 str,
235 '\end{lstlisting}'); 236 '\end{lstlisting}');
236 endfunction 237 endfunction
237 238
238 function outstr = do_bulleted_list (cstr) 239 function outstr = do_bulleted_list (cstr)
240
239 outstr = ["\n" '\begin{itemize}' "\n"]; 241 outstr = ["\n" '\begin{itemize}' "\n"];
240 for i = 1:numel (cstr) 242 for i = 1:numel (cstr)
241 outstr = [outstr, '\item ' cstr{i} "\n"]; 243 outstr = [outstr, '\item ' cstr{i} "\n"];
242 endfor 244 endfor
243 outstr = [outstr, '\end{itemize}' "\n"]; 245 outstr = [outstr, '\end{itemize}' "\n"];
246
244 endfunction 247 endfunction
245 248
246 function outstr = do_numbered_list (cstr) 249 function outstr = do_numbered_list (cstr)
250
247 outstr = ["\n" '\begin{enumerate}' "\n"]; 251 outstr = ["\n" '\begin{enumerate}' "\n"];
248 for i = 1:numel (cstr) 252 for i = 1:numel (cstr)
249 outstr = [outstr, '\item ' cstr{i} "\n"]; 253 outstr = [outstr, '\item ' cstr{i} "\n"];
250 endfor 254 endfor
251 outstr = [outstr, "\\end{enumerate}\n"]; 255 outstr = [outstr, "\\end{enumerate}\n"];
256
252 endfunction 257 endfunction
253 258
254 function outstr = do_graphic (str) 259 function outstr = do_graphic (str)
255 outstr = sprintf ("%s\n", 260 outstr = sprintf ("%s\n",
256 '\begin{figure}[!ht]', 261 '\begin{figure}[!ht]',
301 function outstr = do_R () 306 function outstr = do_R ()
302 outstr = '\textregistered '; 307 outstr = '\textregistered ';
303 endfunction 308 endfunction
304 309
305 function str = do_escape_special_chars (str) 310 function str = do_escape_special_chars (str)
311
306 ## Escape \, {, }, &, %, #, _, ~, ^, <, > 312 ## Escape \, {, }, &, %, #, _, ~, ^, <, >
307 str = regexprep (str, '\\', "\\ensuremath{\\backslash}"); 313 str = regexprep (str, '\\', "\\ensuremath{\\backslash}");
308 str = regexprep (str, '(?<!\\)(\{|\}|&|%|#|_)', '\\$1'); 314 str = regexprep (str, '(?<!\\)(\{|\}|&|%|#|_)', '\\$1');
309 ## Revert accidental {} replacements for backslashes 315 ## Revert accidental {} replacements for backslashes
310 str = strrep (str, '\ensuremath\{\backslash\}', '\ensuremath{\backslash}'); 316 str = strrep (str, '\ensuremath\{\backslash\}', '\ensuremath{\backslash}');
311 str = regexprep (str, '(?<!\\)~', "\\ensuremath{\\tilde{\\;}}"); 317 str = regexprep (str, '(?<!\\)~', "\\ensuremath{\\tilde{\\;}}");
312 str = regexprep (str, '(?<!\\)\^', "\\^{}"); 318 str = regexprep (str, '(?<!\\)\^', "\\^{}");
313 str = regexprep (str, '(?<!\\)<', "\\ensuremath{<}"); 319 str = regexprep (str, '(?<!\\)<', "\\ensuremath{<}");
314 str = regexprep (str, '(?<!\\)>', "\\ensuremath{>}"); 320 str = regexprep (str, '(?<!\\)>', "\\ensuremath{>}");
315 endfunction 321
322 endfunction