소스 파일 : /base_utils/mathjax_config.php (2020-04-12)     소스 설명 : (공통) 수학 표현식용 MathJax inline 설정
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
<?php // (2022.8.26, 차재복, Cha Jae Bok, http://www.ktword.co.kr) 

	// MathJax inline 설정 (설정 파일에 의해서가 아니고 inline 설정 방법)
	echo "<script type='text/x-mathjax-config'>
				MathJax.Hub.Config({
				    extensions: ['tex2jax.js'],
					showMathMenu: false,
					messageStyle: 'none',
				    jax: ['input/TeX', 'output/CommonHTML'],
					TeX: {
						extensions: ['AMSmath.js','AMSsymbols.js']
					},
					tex2jax: {
						inlineMath:  [['{#','#}']],
						displayMath: [['[#','#]']],
						skipTags: ['script','noscript','style','textarea','code','a']
					},
					displayAlign: 'left',
//					displayIndent: '3em',
/*
					'HTML-CSS': {
						showMathMenu: 'false',
						styles: {
						  '.MathJax_Display' : {
							  margin: '0 0 0 0', // 13px
							  padding: '0'
							}
						}
					}
*/
				});
			</script>";

	// MathJax 자바스크립트 원본파일을 클라우드로부터 다운로드 (로드될 때 직전 inline 설정에 따라 적합한 모듈들이 포함됨)
	echo "<script type='text/javascript' async 
			  src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js'>
			</script>";
			// ver 2.7.5 : 2018-07-20 

	// mathjax 경우에, div inline-block 요소로 감쌈
	function mathjax_div_wrap($abbr) {
		$right_bk = 0;
		while (($left_bk=strpos($abbr,'[#',$right_bk)) and ($right_bk=strpos($abbr,'#]',$left_bk))) {
			$left_str = substr($abbr,0,$left_bk);
			$right_str = substr($abbr,$right_bk+strlen('#]'));

			$math_word_len = $right_bk + strlen('#]') - $left_bk;
			$math_word = substr($abbr, $left_bk, $math_word_len);
			$replaced = "<div style='display:inline-block;'>".$math_word."</div>"; // ."sp={$sp},ln={$ln}"

			$abbr = $left_str . $replaced . $right_str;

			$right_bk = $left_bk + strlen($replaced);
		}
		return $abbr;
	}
	
?>


Copyrightⓒ written by 차재복 (Cha Jae Bok)               기술용어해설 후원
"본 웹사이트 내 모든 저작물은 원출처를 밝히는 한 자유롭게 사용(상업화포함) 가능합니다"