This repository was archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwp-quicklatex.php
More file actions
2302 lines (1919 loc) · 81.4 KB
/
wp-quicklatex.php
File metadata and controls
2302 lines (1919 loc) · 81.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: WP QuickLaTeX
Plugin URI: http://www.holoborodko.com/pavel/quicklatex/
Description: Access to complete LaTeX distribution. Publish formulae & graphics using native LaTeX syntax directly in the text. Inline formulas, displayed equations auto-numbering, labeling and referencing, AMS-LaTeX, <code>TikZ</code>, custom LaTeX preamble. No LaTeX installation required. Easily customizable using UI dialog. Actively developed and maintained. Visit <a href="http://www.holoborodko.com/pavel/quicklatex/">QuickLaTeX homepage</a> for more info.
Version: 3.8.3
Author: Pavel Holoborodko
Author URI: http://www.holoborodko.com/pavel/
Copyright: Pavel Holoborodko
License: GPL2
*/
/*
Advanced LaTeX plugin for Wordpress.
Project homepage: http://www.holoborodko.com/pavel/quicklatex/
Contact e-mail: pavel@holoborodko.com
Copyright 2008-2015 Pavel Holoborodko
All rights reserved.
Contributors:
Dmitriy Gubanov - server side development (http://cityjin.com)
Kim Kirkpatrick - ideas & plugin development (http://qm-interpretation.com/)
Ulrich Pinkall - feature suggests (http://www3.math.tu-berlin.de/geometer/wordpress/vismathWS10/)
Rob J. Hyndman - feature suggests (http://robjhyndman.com/)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Redistributions of any form whatsoever must retain the following
acknowledgment:
"
This product includes software developed by Pavel Holoborodko
Web: http://www.holoborodko.com/pavel/
e-mail: pavel@holoborodko.com
"
4. This software cannot be, by any means, used for any commercial
purpose without the prior permission of the copyright holder.
5. This software is for individual usage only. It cannot be used as a part
of blog hosting services for multiple users like WordPress MU or any other
"software as a service" systems without the prior permission of the copyright holder.
Any of the above conditions can be waived if you get permission from
the copyright holder.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
define("QUICKLATEX_PRODUCTION", true);
// Prevent direct call to this php file
if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
// Version check
global $wp_version;
$exit_msg='WP QuickLaTeX requires Wordpress 2.8 or newer. Please update!';
if (version_compare($wp_version,"2.8","<")){
exit ($exit_msg);
}
if( !class_exists( 'WP_Http' ) )
include_once( ABSPATH . WPINC. '/class-http.php' );
// Define some constants http://codex.wordpress.org/Determining_Plugin_and_Content_Directories
if ( ! defined( 'WP_CONTENT_DIR' ) )
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
if ( ! defined( 'WP_PLUGIN_DIR' ) )
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
if ( ! defined( 'WP_QUICKLATEX_PLUGIN_DIR' ) )
define( 'WP_QUICKLATEX_PLUGIN_DIR', plugin_dir_url(__FILE__));
if ( ! defined( 'WP_QUICKLATEX_CACHE_DIR' ) )
define( 'WP_QUICKLATEX_CACHE_DIR', WP_CONTENT_DIR.'/ql-cache' );
if ( ! defined( 'WP_QUICKLATEX_CACHE_URL' ) )
define( 'WP_QUICKLATEX_CACHE_URL', content_url(). '/ql-cache' );
// Default settings (you can use the filter to modify these)
$def_options = array(
'font_size' => 17, // 17px
'font_color' => '000000', // black text
'bg_type' => 0, // Transparent
'bg_color' => 'ffffff', // white background if opaque
'latex_mode' => 0, // auto mode
'preamble' => "\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n",
'use_cache' => 1, // use cache
'show_errors' => 0, // 0 - do not show errors
'add_footer_link' => 0, // 0 - do not use it
'is_preamble_corrected' => 1, // is preamble corrected
'displayed_equations_align' => 0, // 0 - center, 1 - left, 2 -right
'eqno_align' => 0, // 0 - right, 1 - left
// Plugin always handles [latex]...[/latex] tags and $$ .. $$, $$! ... $$ for compatibility
// with older plugin versions.
// User can use additional settings:
'latex_syntax' => 0, // 0 - Compatibility with LaTeX :
// \( ... \), $ ... $ - inline formulas, use \$ to escape $ from compilation
// \[ ... \], $$ .. $$ - displayed equations
// \begin{equation[*]} ... \end{equation}
// \begin{align[*]} ... \end{align}
// \begin{gather[*]} ... \end{gather}
// \begin{multline[*]} ...
// \begin{flalign[*]} ...
// \begin{eqnarray[*]} ...
// \begin{alignat[*]} ...
// \begin{displaymath[*]} ...
'exclude_dollars' => 0, // 1 - Exclude $ ... $ from processing
'image_format' => 3 // Image Format:
// 0 - GIF
// 1 - PNG
// 2 - SVG
// 3 - Automatic
);
// Set Globals to Defaults
$ql_size = $def_options['font_size'];
$ql_color = $def_options['font_color'];
$ql_bg_type = $def_options['bg_type'];
$ql_bg_color = $def_options['bg_color'];
$ql_mode = $def_options['latex_mode'];
$ql_preamble = quicklatex_sanitize_text($def_options['preamble']);
$ql_use_cache = $def_options['use_cache'];
$ql_show_errors = $def_options['show_errors'];
$ql_link = $def_options['add_footer_link'];
$ql_eqalign = $def_options['displayed_equations_align'];
$ql_eqnoalign = $def_options['eqno_align'];
$ql_latexsyntax = $def_options['latex_syntax'];
$ql_exclude_dollars = $def_options['exclude_dollars'];
$ql_imageformat = $def_options['image_format'];
$ql_nlspage = $ql_latexsyntax; // Do we have NLS page or not?
// Autonumbering.
// Set equation number to 1 on the page start
$ql_autoeqno = 1;
// Set default global settings
$ql_atts = null;
// \label{}, \ref{} mechanics
$ql_label_eqno = null;
$ql_label_link = null;
// Diagnostic
$ql_fpp = 0;
// Register main actions
add_action('init','quicklatex_init');
add_action('admin_init', 'quicklatex_admin_init');
add_action('admin_menu', 'quicklatex_menu');
add_action('wp_print_scripts', 'quicklatex_frontend_scripts');
if (function_exists('register_uninstall_hook'))
register_uninstall_hook(__FILE__, 'uninstall_quicklatex');
//Load Styles, Create DB, Register hooks
function quicklatex_init()
{
global $def_options;
//Get access to global variables
global $ql_size, $ql_color, $ql_bg_type, $ql_bg_color, $ql_mode, $ql_preamble, $ql_use_cache, $ql_show_errors, $ql_link;
global $ql_eqalign, $ql_eqnoalign, $ql_latexsyntax;
global $ql_exclude_dollars, $ql_nlspage, $ql_atts;
global $ql_autoeqno;
global $ql_imageformat;
global $ql_label_eqno;
global $ql_label_link;
// Register Styles
wp_register_style('wp-quicklatex-format', WP_QUICKLATEX_PLUGIN_DIR.'css/quicklatex-format.css');
wp_enqueue_style('wp-quicklatex-format');
// Check do we have options in DB. Write defaults if not.
$g_options = get_option('quicklatex');
if($g_options == false)
{
// Write Default options to DB
update_option('quicklatex',$def_options);
}else{
// Add options to DB
//1. AMS - packages.
if(isset($g_options['is_preamble_corrected'])==false) // Do we have it in DB?
{
$preamble = trim($g_options['preamble']);
if($preamble == '')
{
// Just setup include ams-packages to the preamble, if it is empty
$preamble = "\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n";
}else{
// Check whether preamble already has ams packages one by one and add them if not.
if (strpos($preamble, "amssymb") === false) $preamble ="\\usepackage{amssymb}\n".$preamble;
if (strpos($preamble, "amsfonts") === false) $preamble ="\\usepackage{amsfonts}\n".$preamble;
if (strpos($preamble, "amsmath") === false) $preamble ="\\usepackage{amsmath}\n".$preamble;
}
// Setup & add options to DB
$g_options['preamble'] = $preamble;
$g_options['is_preamble_corrected'] = 1;
}
// Displayed Equations Alignment
if(isset($g_options['displayed_equations_align'])==false) // Do we have it in DB?
{
// Setup & add options to DB
$g_options['displayed_equations_align'] = 0;
}
// Displayed Equations Numbering Alignment
if(isset($g_options['eqno_align'])==false) // Do we have it in DB?
{
// Setup & add options to DB
$g_options['eqno_align'] = 0;
}
// Syntax compatible with LaTeX
if(isset($g_options['latex_syntax'])==false) // Do we have it in DB?
{
// Setup & add options to DB
$g_options['latex_syntax'] = 0;
}
// Syntax compatible with LaTeX
if(isset($g_options['exclude_dollars'])==false) // Do we have it in DB?
{
// Setup & add options to DB
$g_options['exclude_dollars'] = 0;
}
// Image Format
if(isset($g_options['image_format'])==false) // Do we have it in DB?
{
// Setup & add options to DB
$g_options['image_format'] = 1;
}else{
// Switch from GIF to PNG
if($g_options['image_format']==0) $g_options['image_format'] = 1;
}
// Add all new fields to DB
update_option('quicklatex',$g_options);
}
// Load current options from DB to globals
//$g_options = get_option('quicklatex');
$ql_size =$g_options['font_size'];
$ql_color =$g_options['font_color'];
$ql_bg_type =$g_options['bg_type'];
$ql_bg_color =$g_options['bg_color'];
$ql_mode =$g_options['latex_mode'];
$ql_preamble =quicklatex_sanitize_text($g_options['preamble']);
$ql_use_cache =$g_options['use_cache'];
$ql_show_errors =$g_options['show_errors'];
$ql_link =$g_options['add_footer_link'];
$ql_eqalign =$g_options['displayed_equations_align'];
$ql_eqnoalign =$g_options['eqno_align'];
$ql_latexsyntax =$g_options['latex_syntax'];
$ql_exclude_dollars =$g_options['exclude_dollars'];
$ql_imageformat =$g_options['image_format'];
$ql_nlspage =$ql_latexsyntax; // Do we have NLS page or not?
// Autonumbering.
// Set equation number to 1 on the page start
$ql_autoeqno = 1;
// Set default global settings
$ql_atts = null;
// \label{}, \ref{} mechanics
$ql_label_eqno = null;
$ql_label_link = null;
// Register filters
add_filter( 'the_content', 'quicklatex_parser',7);
add_filter( 'comment_text', 'quicklatex_parser',7);
add_filter( 'the_title', 'quicklatex_parser',7);
add_filter( 'the_excerpt', 'quicklatex_parser',7);
add_filter( 'thesis_comment_text', 'quicklatex_parser',7);
add_filter( 'plugin_action_links', 'quicklatex_action_links', 10, 2);
}
function quicklatex_menu()
{
if (function_exists('add_menu_page'))
{
$page = add_menu_page(
'QuickLaTeX', // $page_title
'QuickLaTeX', // $menu_title
'manage_options', // $capability, http://codex.wordpress.org/Roles_and_Capabilities
'quicklatex-settings', // $menu_slug
'quicklatex_options_do_page', // $function which generates admin page
WP_QUICKLATEX_PLUGIN_DIR.'images/quicklatex_menu_icon.png' //$icon_url
);
// Using registered $page handle to hook script load
// http://codex.wordpress.org/Function_Reference/wp_enqueue_script
add_action('admin_print_scripts-'. $page, 'quicklatex_admin_scripts');
add_action('admin_print_styles-'. $page, 'quicklatex_admin_styles');
}
if (function_exists('add_submenu_page'))
{
//add_submenu_page('wp-quicklatex/wp-quicklatex-admin.php','Options', 'Options', 'manage_options', 'wp-quicklatex/wp-quicklatex-admin.php');
//add_submenu_page('wp-quicklatex/wp-quicklatex-admin.php','Uninstall', 'Uninstall', 'manage_options', 'wp-quicklatex/wp-quicklatex-uninstall.php');
}
}
function quicklatex_frontend_scripts()
{
// Load JS on front page
if (!is_admin())
{
wp_enqueue_script('jquery');
wp_enqueue_script('wp-quicklatex-frontend', WP_QUICKLATEX_PLUGIN_DIR.'js/wp-quicklatex-frontend.js', array('jquery'), '1.0');
}
}
function quicklatex_admin_scripts()
{
// Load JS on admin page
wp_enqueue_script('jquery');
wp_enqueue_script('postbox');
wp_enqueue_script('wp-quicklatex-colorpicker', WP_QUICKLATEX_PLUGIN_DIR.'js/colorpicker/js/colorpicker.js', array('jquery'), '1.0');
wp_enqueue_script('wp-quicklatex-icheckbox', WP_QUICKLATEX_PLUGIN_DIR.'js/icheckbox/js/icheckbox.js', array('jquery'), '1.0');
wp_enqueue_script('jquery-form',array('jquery') ); // KAK AJAX
wp_enqueue_script('jquery-ui-tabs',array('jquery','jquery-ui-core','jquery-ui-widget') ); // KAK UI
}
function quicklatex_admin_styles()
{
wp_register_style('wp-quicklatex-plugin', WP_QUICKLATEX_PLUGIN_DIR.'css/quicklatex-plugin.css');
wp_enqueue_style('wp-quicklatex-plugin');
wp_register_style('wp-quicklatex-colorpicker', WP_QUICKLATEX_PLUGIN_DIR.'js/colorpicker/css/colorpicker.css');
wp_enqueue_style('wp-quicklatex-colorpicker');
wp_register_style('wp-quicklatex-icheckbox', WP_QUICKLATEX_PLUGIN_DIR.'js/icheckbox/css/icheckbox.css');
wp_enqueue_style('wp-quicklatex-icheckbox');
wp_enqueue_style('jquery-ui', WP_QUICKLATEX_PLUGIN_DIR.'css/smoothness/jquery-ui-1.8.9.custom.css'); // KAK UI
}
function quicklatex_action_links($links, $file) {
static $this_plugin;
if (!$this_plugin) {
$this_plugin = plugin_basename(__FILE__);
}
if ($file == $this_plugin) {
// The "page" query string value must be equal to the slug
// of the Settings admin page we defined earlier, which in
// this case equals "myplugin-settings".
$settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=quicklatex-settings">Settings</a>';
array_unshift($links, $settings_link);
}
return $links;
}
// Delete DB entry on uninstall
function uninstall_quicklatex()
{
delete_option("quicklatex");
}
// Register the plugin's setting
function quicklatex_admin_init()
{
//http://planetozh.com/blog/2009/05/handling-plugins-options-in-wordpress-28-with-register_setting/
register_setting( 'quicklatex_options', 'quicklatex', 'quicklatex_validate_options');
}
// Validate user input
// http://ottodestruct.com/blog/2009/wordpress-settings-api-tutorial/
function quicklatex_validate_options($input)
{
$newinput = $input;
$newinput['font_color'] = quicklatex_sanitize_color(trim($input['font_color']));
if($newinput['bg_type']==1)
{
// if opaque - sanitize color
$newinput['bg_color'] = quicklatex_sanitize_color(trim($input['bg_color']));
}
$newinput['preamble'] = trim($input['preamble']);
// Form doesn't send checkbox value if it is set to off.
// So we should check that manually
if (isset($newinput['use_cache']) == false ) $newinput['use_cache'] = 0;
if (isset($newinput['show_errors']) == false ) $newinput['show_errors'] = 0;
if (isset($newinput['latex_syntax']) == false ) $newinput['latex_syntax'] = 0;
if (isset($newinput['exclude_dollars']) == false ) $newinput['exclude_dollars'] = 0;
// Make sure we never get GIF
if($newinput['image_format']==0) $newinput['image_format'] = 1;
// POST sends only fields being used on the form
// Fill out all other fields - otherwise they are not stored in the DB!!!!
$options = get_option('quicklatex');
$newinput = wp_parse_args($newinput, $options);
return $newinput;
}
function quicklatex_options_do_page()
{
?>
<?php $options = get_option('quicklatex'); ?>
<?php
if( $options['use_cache'] == 1 )
if( false == is_quicklatex_cache_writable(WP_QUICKLATEX_CACHE_DIR) )
echo '<div id="message" class="error"><p style="line-height:150%;"><strong>QuickLaTeX cannot access cache directory for formula images: <i>'.WP_QUICKLATEX_CACHE_DIR.'</i></strong>.<br />'.'Please create it and make sure it is writeable (by <span class="ql-code" style="font-size:13px;">chmode 755</span> or through File Manager in cPanel).'.'<br />'.'<strong>Do not ignore this warning -- caching is crucial for performance of your site.</strong>'.'</p></div>';
?>
<div id="wrap" >
<div id="ql-header">
<!-- Logo -->
<p style="text-align:center;width:70%;">
<img <?php echo 'src="'.WP_QUICKLATEX_PLUGIN_DIR.'images/quicklatex_logo.gif'.'"'; ?> alt="QuickLaTeX Logo"/>
</p>
</div>
<div id="holder">
<div class="metabox-holder">
<!-- settings area -->
<form id="optionsform" method="post" action="options.php"> <!-- AJAX id added -->
<?php settings_fields('quicklatex_options'); ?>
<div id="tabs">
<ul>
<li><a href="#tab-welcome">Getting started</a></li>
<li><a href="#tab-basic">Basic Settings</a></li>
<li><a href="#tab-advanced">Advanced</a></li>
<li><a href="#tab-system">System</a></li>
<li><a href="#tab-about">About</a></li>
</ul>
<!-- Welcome -->
<div id="tab-welcome">
<p>
Activate QuickLaTeX on a page, post, or comment with the shortcode <span class="ql-code">[latexpage]</span>. Then you may insert LaTeX expressions directly in the text by surrounding them with <span class="ql-code">$..$</span> or place them displayed with <span class="ql-code">\[..\]</span> as you usually do typing offline LaTeX documents.
</p>
<p>
You may also use display environments <span class="ql-code">equation, align, displaymath, eqnarray, multline, flalign, gather, and alignat</span>.
</p>
<p>
Here is example of a page with LaTeX formulas (how it appears in Wordpress editor):
</p>
<div class="ql-examples">
[latexpage]<br />
At first, we sample $f(x)$ in the $N$ ($N$ is odd) equidistant points around $x^*$:<br />
\[<br />
f_k = f(x_k),\: x_k = x^*+kh,\: k=-\frac{N-1}{2},\dots,\frac{N-1}{2}<br />
\]<br />
where $h$ is some step.<br />
Then we interpolate points $\{(x_k,f_k)\}$ by polynomial <br />
\begin{equation} \label{eq:poly}<br />
P_{N-1}(x)=\sum_{j=0}^{N-1}{a_jx^j}<br />
\end{equation}<br />
Its coefficients $\{a_j\}$ are found as a solution of system of linear equations:<br />
\begin{equation} \label{eq:sys}<br />
\left\{ P_{N-1}(x_k) = f_k\right\},\quad k=-\frac{N-1}{2},\dots,\frac{N-1}{2}<br />
\end{equation}<br />
Here are references to existing equations: (\ref{eq:poly}), (\ref{eq:sys}).<br />
Here is reference to non-existing equation (\ref{eq:unknown}).<br />
</div>
<p>
Same page processed by QuickLaTeX and published (how visitors see it in a browser):
</p>
<p style="text-align:center;">
<img <?php echo 'src="'.WP_QUICKLATEX_PLUGIN_DIR.'images/example-1.png'.'"'; ?> alt="QuickLaTeX Example"/>
</p>
<p>
For the display environments, equation numbering is automatic, but this may be overridden and the number set explicitly with <span class="ql-code">\tag{..}</span> placed within the display expression.
</p>
<p>
A number of options may be set for an expression with attribute tags such as <span class="ql-code"> size, color, background, align</span>, as arguments of <span class="ql-code">\quicklatex{}</span> placed within the expression:
</p>
<div class="ql-examples">
\[<br />
\quicklatex{color="#00ff00" size=25}<br />
\boxed{f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1}<br />
\]<br />
</div>
<p>
renders with green font of 25 pixels height:
</p>
<p style="text-align:center;">
<img <?php echo 'src="'.WP_QUICKLATEX_PLUGIN_DIR.'images/example-2.png'.'"'; ?> alt="QuickLaTeX Example"/>
</p>
<p>
Compilation of an expression may be suppressed, showing instead the LaTeX source, by preceding the expression with a <span class="ql-code">!</span>.
</p>
<p>
For mathematical graphs you may use <span class="ql-code">tikzpicture</span> and <span class="ql-code">pgfplots</span>, e.g. :
</p>
<div class="ql-examples">
\begin{tikzpicture}<br />
[+preamble]<br />
\usepackage{pgfplots}<br />
\pgfplotsset{compat=newest}<br />
[/preamble]<br />
\begin{axis}<br />
\addplot3[surf,domain=0:360,samples=40] {cos(x)*cos(y)};<br />
\end{axis}<br />
\end{tikzpicture}
</div>
<p>
compiles to
</p>
<p style="text-align:center;">
<img <?php echo 'src="'.WP_QUICKLATEX_PLUGIN_DIR.'images/example-3.png'.'"'; ?> alt="QuickLaTeX Example"/>
</p>
<p>
see <a href="http://www.holoborodko.com/pavel/quicklatex/" target="_blank">on-line tikz help</a> for examples and more information.
</p>
<p>
Whether or not QuickLaTeX has been activated with <span class="ql-code">[latexpage]</span>, you may always place a LaTeX expression within <span class="ql-code">[latex] .. [/latex]</span> shortcodes everywhere on the site. Attribute tags are allowed: <span class="ql-code">[latex attrs]...[/latex]</span>.
</p>
<p class="ql-head-desc">
Visit <a href="http://www.holoborodko.com/pavel/quicklatex/" target="_blank">QuickLaTeX's home page</a> for more information on features, examples, tips & tricks, <span class="ql-code">tikZ</span> graphics inclusion, etc.
</p>
</div>
<!-- Basic settings -->
<div id="tab-basic">
<p class="ql-heading ql-bottom-border">
Set default styling. These settings can be overridden on a per formula basis using <span class="ql-code">\quicklatex{}</span> within its LaTeX code. For more precise tuning, modify <span class="ql-code">quicklatex-format.css</span>.
</p>
<table class="form-table">
<tbody>
<!-- Font Size -->
<tr>
<th valign="top" scope="row">Font Size</th>
<td valign="top">
<select name="quicklatex[font_size]" class="select">
<?php
for($i=5;$i<101;$i++)
{
if ($i==$options['font_size']){
echo '<option value="'.$i.'"'.'selected="selected">'.$i.'px</option>';
}else{
echo '<option value="'.$i.'">'.$i.'px</option>';
}
}
?>
</select>
</td>
<td></td>
</tr>
<tr class="ql-row">
<td class="ql-desc" colspan="3">
<small>
Choose formula font size to match text on your website.
</small>
</td>
</tr>
<!-- Font Color -->
<tr class="ql-row even">
<th valign="top" scope="row">Font Color</th>
<td valign="top">
<input class="text" id="textcolor" type="text" name="quicklatex[font_color]" value="<?php echo $options['font_color']; ?>"/>
</td>
<td> </td>
</tr>
<tr class="ql-row even">
<td class="ql-desc" colspan="3">
<small>
RGB triplet in CSS format - six digit hexadecimal number.
Please see <a href="http://w3schools.com/css/css_colors.asp">CSS Colors</a> for examples.
</small>
</td>
</tr>
<!-- Background Color -->
<tr class="ql-row">
<th valign="top">
Background Color
</th>
<td>
<select class="select" name="quicklatex[bg_type]" id="bgcolor_combobox">
<?php
echo '<option value="0"'.(0==$options['bg_type']?'selected="selected"':'').'>'.'Transparent'.'</option>';
echo '<option value="1"'.(1==$options['bg_type']?'selected="selected"':'').'>'.'Opaque'.'</option>';
?>
</select>
</td>
<td>
<input class="text" type="text" id="bkgcolor" name="quicklatex[bg_color]" value="<?php echo $options['bg_color']; ?>"/>
</td>
</tr>
<tr class="ql-row">
<td class="ql-desc" colspan="3">
<small>
Formulas are rendered with transparent background by default. Setup opaque color in <a href="http://w3schools.com/css/css_colors.asp">CSS format</a> otherwise.
</small>
</td>
</tr>
</tbody>
</table>
<table class="form-table">
<tbody>
<!-- Displayed Equations Alignment -->
<tr class="ql-row">
<th valign="top" scope="row">Displayed Equations Alignment</th>
<td valign="top">
<select class="select" name="quicklatex[displayed_equations_align]">
<?php
echo '<option value="0"'.(0==$options['displayed_equations_align']?'selected="selected"':'').'>'.'center'.'</option>';
echo '<option value="1"'.(1==$options['displayed_equations_align']?'selected="selected"':'').'>'.'left'.'</option>';
echo '<option value="2"'.(2==$options['displayed_equations_align']?'selected="selected"':'').'>'.'right'.'</option>';
?>
</select>
</td>
<td></td>
</tr>
<!-- Equation Number Position -->
<tr class="ql-row even">
<th valign="top" scope="row">Equation Number Position</th>
<td valign="top">
<select class="select" name="quicklatex[eqno_align]">
<?php
echo '<option value="0"'.(0==$options['eqno_align']?'selected="selected"':'').'>'.'right'.'</option>';
echo '<option value="1"'.(1==$options['eqno_align']?'selected="selected"':'').'>'.'left'.'</option>';
?>
</select>
</td>
<td></td>
</tr>
</tbody>
</table>
<div class="ql-alignright">
<input class='button-primary' type='submit' name='submit' value='<?php _e('Update QuickLaTeX Settings »'); ?>' />
</div>
<br class="clear" />
</div>
<!-- System settings -->
<div id="tab-system">
<p class="ql-heading ql-bottom-border">
QuickLaTeX converts formulas into SVG/PNG images and tries to cache them on your site for maximum performance.<br />
By default QuickLaTeX is tolerant to mistakes in LaTeX code and stops only on critical errors.<br />
You can tune these settings here.<br />
</p>
<table class="form-table">
<tbody>
<!-- Image Format -->
<tr class="ql-row even">
<th valign="top" scope="row">Image format</th>
<td valign="top">
<select class="select" name="quicklatex[image_format]" id="imgformat_combobox">
<?php
echo '<option value="0"'.(0==$options['image_format']?'selected="selected"':'').'disabled="disabled">'.'GIF'.'</option>';
echo '<option value="1"'.(1==$options['image_format']?'selected="selected"':'').'>'.'PNG'.'</option>';
echo '<option value="2"'.(2==$options['image_format']?'selected="selected"':'').'>'.'SVG'.'</option>';
echo '<option value="3"'.(3==$options['image_format']?'selected="selected"':'').'>'.'Auto'.'</option>';
?>
</select>
</td>
<td></td>
</tr>
<tr class="ql-row even">
<td class="ql-desc" colspan="3">
<small>
Output image format. 'Auto' is recommended choice.
<!-- SVG is the best, but not implemented yet. In the next versions QuickLaTeX will choose image format automatically depending on visitor's browser capability. -->
</small>
</td>
</tr>
<!-- Cache -->
<tr class="ql-row">
<th valign="top" scope="row">Cache images locally</th>
<td valign="top">
<input type="checkbox" name="quicklatex[use_cache]" value="1" <?php if($options['use_cache']==1)echo 'checked="checked"'; ?>/>
</td>
<td></td>
</tr>
<tr class="ql-row">
<td class="ql-desc" colspan="3">
<small>
Absolutely essential for performance of your site. Also we recommend you to use <a href="http://wordpress.org/extend/plugins/wp-super-cache/">WP Super Cache</a> for optimal speed.
</small>
</td>
</tr>
<!-- Show LaTeX errors & warnings -->
<tr class="ql-row even">
<th valign="top" scope="row">Debug mode</th>
<td valign="top">
<input type="checkbox" name="quicklatex[show_errors]" value="1" <?php if($options['show_errors']==1)echo 'checked="checked"'; ?>/> </td>
<td> </td>
</tr>
<tr class="ql-row even">
<td valign="top" class="ql-desc" colspan="3">
<small>
Forces QuickLaTeX compiler to be strict and show all warnings and errors.
</small>
</td>
</tr>
</tbody>
</table>
<div class="ql-alignright">
<input class='button-primary' type='submit' name='submit' value='<?php _e('Update QuickLaTeX Settings »'); ?>' />
</div>
<br class="clear" />
</div>
<!-- Advanced -->
<div id="tab-advanced">
<p class="ql-heading ql-bottom-border">
QuickLaTeX processes native LaTeX shorthands on the pages activated by <span class="ql-code">[latexpage]</span> tag.<br />
However you can activate LaTeX syntax interpretation sitewide (on every post, page and comment).<br />
No tags are needed in this mode.<br />
</p>
<table class="form-table">
<tbody>
<!-- LaTeX shortcodes -->
<tr class="ql-row">
<th valign="middle" scope="row" style="vertical-align:middle;">Use LaTeX Syntax Sitewide</th>
<td valign="middle">
<input type="checkbox" name="quicklatex[latex_syntax]" value="1" <?php if($options['latex_syntax']==1)echo 'checked="checked"'; ?>/>
</td>
</tr>
<tr class="ql-row">
<td class="ql-desc" colspan="3">
<small>
This option activates LaTeX interpretation on all pages, regardless of the use of <span class="ql-code">[latexpage]</span>. This is useful for a site that is authored exclusively by LaTeX users. If this is turned on, all authors must be made aware that <span class="ql-code">$</span> is a special symbol, and that the standard dollar symbol must be typed <span class="ql-code">$</span>.
</small>
</td>
</tr>
<!-- TeX shortcodes -->
<tr class="ql-row even">
<th scope="row" style="vertical-align:middle;">Exclude <span class="ql-code-big">$ .. $</span></th>
<td valign="middle">
<input type="checkbox" name="quicklatex[exclude_dollars]" value="1" <?php if($options['exclude_dollars']==1)echo 'checked="checked"'; ?>/>
</td>
<td> </td>
</tr>
<tr class="ql-row even">
<td class="ql-desc" colspan="3">
<small>
The use of the traditional TeX <span class="ql-code">$</span> conflicts with the non-LaTeX user's expectation of its meaning. This option allows us to turn its interpretation off, so standard dollar signs need no special treatment and will not confuse the non-mathematical user.
</small>
</td>
</tr>
</tbody>
</table>
<p class="ql-heading-simple" style="margin-top:30px;">
Please setup LaTeX preamble for the whole* website below.<br /> You can define new commands and include additional packages as usual:
</p>
<textarea class="ql-preamble" name="quicklatex[preamble]" rows="10" cols="50"><?php echo $options['preamble']; ?></textarea>
<p class="ql-notes">
*Global preamble can be overriden by <span class="ql-code">[preamble]</span> tag for particular equation.
</p>
<div class="ql-alignright">
<input class='button-primary' type='submit' name='submit' value='<?php _e('Update QuickLaTeX Settings »'); ?>' />
</div>
<br class="clear" />
</div>
<!-- About -->
<div id="tab-about">
<p class="ql-about">
QuickLaTeX is free under linkware license. Which means service can be used: (a) on non-commercial websites; (b) with visible and direct backlink to <a href="http://www.holoborodko.com/pavel/quicklatex/">QuickLaTeX homepage</a>.
</p>
<p class="ql-about">
<strong><span class="ql-powered">"Powered by <a href="http://www.holoborodko.com/pavel/quicklatex/">QuickLaTeX</a>"</span></strong> somewhere on the site would greatly support us and inspire future development.
</p>
■ People behind QuickLaTeX
<DL class="ql-devs">
<DT><a href="http://holoborodko.com/pavel/" target="_blank">Pavel Holoborodko</a></dt>
<DD class="ql-people">Author & core QuickLaTeX developer.</dd>
<DT><a href="http://cityjin.com" target="_blank">Dmitriy Gubanov</a></dt>
<DD class="ql-people">Server-side implementation and administration.</dd>
<DT><a href="http://www.legacy.com/obituaries/santafenewmexican/obituary.aspx?pid=155800823" target="_blank">Kim Kirkpatrick</a> <i>(Miss you my dear friend, may your soul rest in peace)</i></dt>
<DD class="ql-people">Ideas & plugin development.</dd>
</DL>
■ Top idea contributors
<DL class="ql-devs">
<DT><a href="http://robjhyndman.com/" target="_blank">Rob J. Hyndman</a></dt>
<DD class="ql-people">AMS-LaTeX support which lead to custom preamble feature.</dd>
<DT><a href="http://www3.math.tu-berlin.de/geometer/wordpress/vismathWS10/" target="_blank">Ulrich Pinkall</a></dt>
<DD class="ql-people">Native LaTeX syntax embedded directly in the text.</dd>
</DL>
</div>
</div> <!-- tabs -->
</form> <!-- form -->
</div>
</div> <!-- holder -->
<!-- right sidebar -->
<div class="postbox-container" id="likethis">
<div class="metabox-holder">
<div id="ql-support" class="postbox">
<div class="handlediv" title="Click to toggle"><br></div>
<h3 class="hndle"><span>Like QuickLaTeX?</span></h3>
<div class="inside">
<div class="ql-postbox-content">
<p class="ql-p-justified">
<strong>
Want to help make this plugin even better?
Donate to keep new improvements coming!
</strong>
</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="PG7NTGB7YAMXN" />
<table class="ql-el-centered">
<tr><td><input type="hidden" name="on0" value="Pick Your Fibonacci Number" />Pick Your Fibonacci Number</td></tr>
<tr>
<td>
<select name="os0">
<option value="Thanks!" selected="selected">$5.00 - Thanks!</option>
<option value="Two beers">$8.00 - Two beers</option>
<option value="One meal">$13.00 - One meal</option>
<option value="Supporter">$21.00 - Supporter</option>
<option value="1mo Hosting Donator">$34.00 - 1mo Hosting Donator </option>
<option value="2mo Hosting Donator">$55.00 - 2mo Hosting Donator</option>
<option value="Super-human">$89.00 - Super-human</option>
</select>
</td>
</tr>
<tr>
<td style="text-align:center;">
<input type="hidden" name="currency_code" value="USD" />
<input type="image" <?php echo 'src="'.WP_QUICKLATEX_PLUGIN_DIR.'images/donate.gif'.'"'; ?> name="submit" alt="PayPal - The safer, easier way to pay online." />
</td>
</tr>
</table>
</form>
<p class="ql-p-centered">
<small> All donations are used for development of the plugin.</small>
</p>
</div>
</div>
</div> <!-- Like this plugin? -->
<div id="ql-partners" class="postbox">
<div class="handlediv" title="Click to toggle"><br></div>
<h3 class="hndle"><span>Supporters:</span></h3>
<div class="inside">
<p class="ql-p-centered">
<a href="http://www.advanpix.com/" target="_blank">
<img <?php echo 'src="'.WP_QUICKLATEX_PLUGIN_DIR.'images/amct_logo.png'.'"'; ?> alt="Advanpix Multiprecision Computing Toolbox"/>
</a>
</p>
</div>
</div>
</div>
</div>
</div> <!-- wrap -->
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready( function($)
{
$(':checkbox').iphoneStyle();
// postboxes setup
postboxes.add_postbox_toggles('ql-overview');
// Use transparent background color by default
is_bgcolor_visible = <?php if($options['bg_type']==0) echo 'false'; else echo 'true'; ?>;
if(is_bgcolor_visible==true)
{
$("#bkgcolor").show();
}else{
$("#bkgcolor").hide();
}
$("#bgcolor_combobox").change(function () {
$("#bgcolor_combobox option:selected").each(function () {
if($(this).val()==1)
{
$("#bkgcolor").show();
}else{
$("#bkgcolor").hide();
}
});
//$("div#test").text(str);
})
//.trigger('change');
$('#textcolor').ColorPicker({
onChange: function(hsb, hex, rgb, el) {
// Set text color to be visible
$("#textcolor").val(hex);
$("#textcolor").css('background-color', '#' + hex);
if(0.213 * rgb.r + 0.715 * rgb.g +0.072 * rgb.b < 128)
$("#textcolor").css('color', '#FFFFFF');
else
$("#textcolor").css('color', '#000000');
},
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}
}).keyup(function(){
// In case if user edit color field from keyboard:
var color = $(this).val();
// Sanitize color
var len = 6 - color.length;