"Gentoo mwmath"의 두 판 사이의 차이

Gentoo Korea Wiki
둘러보기로 가기 검색하러 가기
 
92번째 줄: 92번째 줄:
  
 
어쨌든 빌드 과정에서 texvc, texvc_test, texvc_tex 세 파일이 나온다. 이걸 /usr/bin 또는 /usr/local/bin 아무데나 export | grep PATH 에 걸린 위치에 복사해주면 된다.
 
어쨌든 빌드 과정에서 texvc, texvc_test, texvc_tex 세 파일이 나온다. 이걸 /usr/bin 또는 /usr/local/bin 아무데나 export | grep PATH 에 걸린 위치에 복사해주면 된다.
 +
 +
그리고 하나가 더 남았다
 +
 +
<syntaxhighlight lang="bash">
 +
[ gentoo math ] # cd ../texvccheck
 +
[ gentoo texcvvheck ] # make
 +
ocamlopt -c util.ml
 +
ocamlc -c tex.mli
 +
ocamlyacc parser.mly
 +
9 shift/reduce conflicts.
 +
ocamlc -c parser.mli
 +
ocamlopt -c parser.ml
 +
ocamlopt -c texutil.ml
 +
ocamllex lexer.mll
 +
344 states, 8879 transitions, table size 37580 bytes
 +
3277 additional bytes used for bindings
 +
ocamlopt -c lexer.ml
 +
ocamlopt -c texvccheck.ml
 +
ocamlopt -o texvccheck unix.cmxa util.cmx parser.cmx texutil.cmx lexer.cmx texvccheck.cmx
 +
rm parser.ml lexer.ml
 +
 +
[ gentoo texcvvheck ] # _
 +
</syntaxhighlight>
 +
 +
여기서 생긴 파일을 역시 /usr/bin 같은 곳에 적절히 복사해주자.
  
 
== 설정 작성 ==
 
== 설정 작성 ==

2014년 5월 30일 (금) 18:37 기준 최신판

개요

수식을 입력할 일이 얼마나 있겠느냐마는 적어도 대학원이나 연구기관 같은 곳에서 위키 페이지에 수학 수식을 그럴싸하게 입력해보고 싶을 때가 있을 것이다. 물론 입력한 내용을 보고서로 만들어야 할 경우 급하게 간단한 포매팅을 제공하는 위키를 통해 수식 내용과 설명을 넣어야 할 필요가 생기기도 한다. 여기에서는 바로 이러한 목적을 달성하기 위한 수단을 완성함을 목표로 내용을 진행하도록 하겠다. 물론 참고로 수식은 TeX문법을 적용해서 입력하도록 설정한다.(MathML은 너무 복잡해서 TeX 수식에 비하면 쓸만하지가 않다)

가져오기

  • 우선 다음의 패키지가 필요하다 (만일을 위해)
[ gentoo ~ ] # emerge texlive-core dvipsk dvipng ghostscript-gpl


참고: 고스트 스크립트는 aclocal의 동작문제로 설치가 안될 수도 있다. 하지만 앞서 걸어놓은 dvipsk와 dvipng를 제대로 설치하고 나면 설치가 안돼도 무방하다


  • 미디어위키의 확장을 설치할 디렉터리로 이동한다. 여기서는 /var/www/mediawiki에 미디어 위키를 설치하고, 확장 기능은 /var/www/mediawiki/extensions에 설치한다고 가정한다.
[ gentoo ~ ] # cd /var/www/mediawiki/extensions


  • git을 설치하지 않았다면 git을 설치한다. 그리고 다음 명령으로 Math 확장 패키지를 가져온다
[ gentoo extensions ] # git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Math.git


  • 별도의 디렉터리(ex. 웹 루트)로 이동하여 수학 수식을 제대로 표시할 MathJax를 가져온다. MathJax는 웹에서 접근 가능해야 한다. MathJax 이전에 수식을 렌더링해서 뿌려주는 서버가 있었지만, MathJax는 서버의 부하를 분산하기 위해 클라이언트 단에서 서버로부터 소스코드를 받아 로컬에서 렌더링을 하고 이미지를 자체적으로 만들어서 출력하게 한다. IEEE, Elsevier 등의 유명한 학술 단체의 지원을 받는 프로젝트인만큼 굉장히 훌륭한 수식 표현 수단이다.
[ gentoo extensions ] # cd /var/www
[ gentoo www ] # git clone git://github.com/mathjax/MathJax.git MathJax

해야 할 일 : 빌드

Math 확장을 가져왔다면 texvc가 있어야 한다. 그런데 이걸 어디서 따로 구할 수 있는건 아니다. 다만! 어떤 프로그램이든 빌드할 준비가 되어 있는 이상 젠투에서는 매우 간단하게 빌드를 처리할 수 있다.

우선 미디어위키 확장을 저장하는 디렉터리로 이동한다

[ gentoo ~ ] # cd /var/www/mediawiki/extensions
[ gentoo extensions ] _

다음 기존에 받은 Math 확장의 math로 이동한다 (대소문자 유의!)

[ gentoo extensions ] # cd Math/math
[ gentoo math ] #

make 라고 입력해보라 다음과 같이 빌드가 되면 OK.

[ gentoo math ] # make
ocamlopt -c util.ml
ocamlc -c render_info.mli
ocamlc -c tex.mli
ocamlyacc parser.mly
9 shift/reduce conflicts.
ocamlc -c parser.mli
ocamlopt -c parser.ml
ocamlc -c html.mli
ocamlopt -c html.ml
ocamlc -c mathml.mli
ocamlopt -c mathml.ml
ocamlc -c texutil.mli
ocamlopt -c texutil.ml
ocamllex lexer.mll
344 states, 8879 transitions, table size 37580 bytes
3277 additional bytes used for bindings
ocamlopt -c lexer.ml
ocamlopt -c render.ml
ocamlopt -c texvc.ml
ocamlopt -o texvc unix.cmxa util.cmx parser.cmx html.cmx mathml.cmx texutil.cmx lexer.cmx render.cmx texvc.cmx
ocamlopt -c texvc_test.ml
ocamlopt -o texvc_test util.cmx parser.cmx html.cmx mathml.cmx texutil.cmx lexer.cmx texvc_test.cmx
ocamlopt -c texvc_tex.ml
ocamlopt -o texvc_tex util.cmx parser.cmx html.cmx mathml.cmx texutil.cmx lexer.cmx texvc_tex.cmx
rm parser.ml lexer.ml

[ gentoo math ] # _

만약 파일 또는 디렉터리가 없다는 메시지가 나오면, ocaml을 이머지한다. 그 전에 활성 가능한 USE 플래그 종류를 확인한다.

[ gentoo math ] # emerge -pav ocaml

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N    ] dev-lang/ocaml-4.01.0:0/4.01.0  USE="X latex ncurses -tk -ocamlopt -emacs -xemacs" 3,607 kB

Total: 1 package (1 reinstall), Size of downloads: 3,607 kB

필요에 따라 /etc/portage/make.conf 파일을 편집하여 USE 플래그를 추가한다.

어쨌든 빌드 과정에서 texvc, texvc_test, texvc_tex 세 파일이 나온다. 이걸 /usr/bin 또는 /usr/local/bin 아무데나 export | grep PATH 에 걸린 위치에 복사해주면 된다.

그리고 하나가 더 남았다

[ gentoo math ] # cd ../texvccheck
[ gentoo texcvvheck ] # make
ocamlopt -c util.ml
ocamlc -c tex.mli
ocamlyacc parser.mly
9 shift/reduce conflicts.
ocamlc -c parser.mli
ocamlopt -c parser.ml
ocamlopt -c texutil.ml
ocamllex lexer.mll
344 states, 8879 transitions, table size 37580 bytes
3277 additional bytes used for bindings
ocamlopt -c lexer.ml
ocamlopt -c texvccheck.ml
ocamlopt -o texvccheck unix.cmxa util.cmx parser.cmx texutil.cmx lexer.cmx texvccheck.cmx
rm parser.ml lexer.ml

[ gentoo texcvvheck ] # _

여기서 생긴 파일을 역시 /usr/bin 같은 곳에 적절히 복사해주자.

설정 작성

  • Math 확장 패키지를 설정할 차례이다. MediaWiki LocalSettings.php 파일에 몇 줄만 넣어주면 된다. 여기서 조건은 서버 도메인은 foo.baz이고 MathJax를 설치할 디렉터리는 /var/www/MathJax 라고 앞서 정했다고 가정한다. (가져오기 단계를 그대로 따랐을 경우)
required_once( "$IP/extensions/Math/Math.php" );

# End of automatically generated settings.
# Add more configuration options below.
$wgUseTeX = true;
$wgUseMathJax = true;
$wgMathJaxUrl = "http://foo.baz/MathJax/MathJax.js?config=TeX-AMS_HTML";
$wgDefaultUserOptions['math'] = MW_MATH_MATHJAX;


테스트

다음과 같은 수식이

\frac{-b\pm\sqrt{b^2-4ac}}{2a}

다음과 같이 출력되어야 한다.

참고