아래의 소스는 koTeX 2012 이상이면 컴파일되는 TeX 소스이다.

TeXworks 에서 XeLaTeX  으로 컴파일하면 에러는 없자만 소스 리스팅 부분이 제대로 반영되지 않는다. 차라리 명령줄애서 --shell-escape 옵션을 주고  xelatex 명령으로 컴파일하는 것이 확실하다.

\begin{pyglist}[language=python,encoding=utf8]

처럼 옵션 encoding=utf8 이 있어야 한글이 출력된다,

 

컴파일하기:

프롬프트> xelatex --shell-escape ex-verbments-01.tex

 

* 파일명:  ex-verbments-01.tex

\documentclass{article}


\usepackage{kotex}

\usepackage{verbments}



\begin{document}

verbments 패키지를 이용한 한글 테스트...


\begin{pyglist}[language=python,encoding=utf8]

#!C:\Python32\python.exe

# EASY-INSTALL-ENTRY-SCRIPT: 'pygments==1.5','console_scripts','pygmentize'

__requires__ = 'pygments==1.5'

import sys

from pkg_resources import load_entry_point


# 한글 주석

if __name__ == '__main__':

    sys.exit(

        load_entry_point('pygments==1.5', 'console_scripts', 'pygmentize')()

    )


\end{pyglist}


\begin{pyglist}[language=c,encoding=utf8]

int main() {

    printf("Hello, 안녕하세요?\n");

}

\end{pyglist}


\end{document}

 

 

출력된 PDF 파일:

ex-verbments-01.pdf

 

 

Posted by Scripter
,

아래의 소스는 koTeX 2012 이상이면 컴파일되는 TeX 소스이다.

TeXworks 에서 XeLaTeX  으로 컴파일하면 -shell-escape 옵션이 필요하다는 에러 메시지가 뜬다.

 

컴파일하기:

프롬프트> xelatex --shell-escape ex-minted-01.tex

 

* 파일명:  ex-minted=01.tex

\documentclass[12pt,a4paper]{article}


\usepackage{kotex}

\usepackage{hyperref}

\usepackage{minted}


\begin{document}


% v\begin{minted}[ruby]

\begin{minted}{ruby}

=begin

Usual operators(평범한 사칙연산자):

+ addition(덧셈)

- subtraction(뺄셈)

* multiplication(곱셈)

/ division(나눗셈)

=end


a = 5 + 3

b = 5 / 3

put "Hello, 안녕하세요?"

\end{minted}


 

출력된 PDF 파일:

ex-minted-01.pdf

 

 

 

Posted by Scripter
,

아래의 소스는 koTeX 2012 이상이면 컴파일되는 TeX 소스이다.

TeXworks 에서 XeLaTeX  으로 컴파일해도 되고, pdfLaTeX 으로 컴파일해도 된다.

한글이 정상적으로 출력되게 하려면,

\begin{lstlisting}[frame=single,escapeinside=~~]

처럼 옵션 escapeinside=~~ 을 주고 ~아무개~ 하면 아무개가 출력된다.

만일 옵션 escapeinside=^$ 을 주었다면 ^아무개$ 해야 아무개가 출력된다.

 

* 파일명:  ex-listings=03.tex

 \documentclass{article}


\usepackage{kotex}

\usepackage[T1]{fontenc}

\usepackage{listings} % Include the listings-package

\usepackage{color}

\usepackage{tikz}


\begin{document}


\lstset{ % Set your language (you can change the language for each code-block optionally)

language=Pascal,

tabsize=2,

extendedchars=true,

texcl=true,

stringstyle=\color{black!50}\ttfamily, basicstyle=\small\sffamily,

numbers=left,

numberstyle=\tiny,

frame=tb,

columns=fullflexible,

showstringspaces=false

}


\begin{lstlisting}[frame=single,escapeinside=~~] % Start your code-block


for i:=maxint to 0 do

begin

{ do nothing }

end;

Write('Case insensitive ');

Write('Pascal keywords ~한글~');

\end{lstlisting}


\lstset{

language=C,

tabsize=2,

extendedchars=true,

texcl=true,

stringstyle=\color{black!50}\ttfamily, basicstyle=\small\sffamily,

numbers=left,

numberstyle=\tiny,

frame=tb,

columns=fullflexible,

showstringspaces=false

inputencoding=utf8

}


\vspace{1cm}


\begin{lstlisting}[escapeinside=~~]

#include <stdio.h>


#define N 10


/* Block ~블록~

* comment ~커멘트~ */

int main()

{

int i;

// Line comment.

puts("Hello world! ~안녕?~");

for (i = 0; i < N; i++)

{

puts("LaTeX is also great for programmers!");

}

return 0;

}

\end{lstlisting}


\end{document}


 

출력된 PDF 파일: 

ex-listings-03.pdf

 

 

 

 

 

Posted by Scripter
,
\begin{cases}를 이용한 연립방정식 표현
\parstyle 연립방정식 $\begin{cases} x + 2000y - 500z= 1 \\ 90000x - 1000y + z = 2000 \\ 7x - 8y + 3z = -3 \end{cases}$ 을 푸시오.


systeme 패키지를 이용한 연립방정식 표현
\parstyle \usepackage{systeme} 연립방정식 \systeme{x + 2000y - 500z= 1, 90000x - 1000y + z = 2000 , 7x - 8y + 3z = -3 } 을 푸시오.

※ texdoc systeme 명령을 내리면 (불어로 된) systeme 사용 설명서를 볼 수 있습니다.



Posted by Scripter
,
mathkotex 으로 레이텍(LaTeX)의 TikZ 패키지를 사용하여 프랙탈 이미지 출력 테스트입니다.
(아래의 이미지는 TikZ 패키지를 사용하여 생성되었습니다.
text 태그로 둘러싸인 부분에서
\pdf
대신에
\documentclass{article}
로 바꾸면, textlive 2011 이 설치된 시스템에서 pdflatex 명령으로 컴파일해도 됩니다.)

\pdf \usepackage{pgf} \usepackage{tikz} \usetikzlibrary{decorations} \usetikzlibrary{decorations.fractals} \usetikzlibrary{lindenmayersystems} \begin{document} \begin{tikzpicture}[decoration=Koch curve type 1] \draw decorate{ (0,0) -- (3,0) }; \draw decorate{ decorate{ (0,-1.5) -- (3,-1.5) }}; \draw decorate{ decorate{ decorate{ (0,-3) -- (3,-3) }}}; \end{tikzpicture} \end{document}




<tex> \pdf \usepackage{pgf} \usepackage{tikz} \usetikzlibrary{decorations} \usetikzlibrary{decorations.fractals} \usetikzlibrary{lindenmayersystems} \begin{document} \begin{tikzpicture}[decoration=Koch curve type 1] \draw decorate{ (0,0) -- (3,0) }; \draw decorate{ decorate{ (0,-1.5) -- (3,-1.5) }}; \draw decorate{ decorate{ decorate{ (0,-3) -- (3,-3) }}}; \end{tikzpicture} \end{document} </tex>

라고 입력하면 위의 저 그림이 출력됩니다.

그렇게 하기 위해서는 HTML 문서에 당연히
<script type="text/javascript" src="http://www.ezsolver.co.kr/mathkotex_tag.js"> </script>
를 추가해야 합니다. 아니면 더 기억하기 쉬운 자바스크립트 URL 주소
<script type="text/javascript" src="http://www.mathkotex.com/mathkotex_tag.js"> </script>
를 추가해도 됩니다.



Posted by Scripter
,
좀 오래된 폰트이지만 유니코드를 지원하므로 다국어 문서를 만들 때 필요한 폰트입니다.

위의 압축파일을 풀어서 나오는 CODE2000.TTF 파일을 C:\Windows\Fonts 폴더에 갖다 놓으면 TeX에서 바로 쓸 수 있습니다.


* XeLaTeX 으로 컴파일되는 예제 소스
  (소스는 반드시 utf-8 인코딩으로 저장되어야 합니다.)

% use article styling for this document

% Modified from: http://wiki.xelatex.org/doku.php?id=basic_document

\documentclass{article}

% enable system font access

\usepackage{fontspec}

% styling: Palatino (main text), Helvetica (stress), Code2000 (exotic text) and Asana Math (for math things)

\setmainfont{Palatino Linotype}

\newfontfamily{\maintext}{Palatino Linotype}

\newfontfamily{\stressed}{Helvetica}

\newfontfamily{\exotic}{Code2000}

\newfontfamily{\math}{Asana Math}

% start of actual document

\begin{document}

This is a basic XeLaTeX document, which will be processes using the {\stressed xelatex} program.

This means that as long as the document source is in {\stressed UTF-8} encoding,

XeLaTeX {\stressed doesn't care} what you actually wrote.

For instance, we can write in English, or in Korean ({\exotic 한글}), Japanese ({\exotic 日本語}), or in Thai

({\exotic ภาษาไทย}), or in Vietnamese ({\exotic tiếng Việt}), or any other number of languages.

It can even be used for non-languages that are in {\stressed Unicode},

such as mathematical operators (like {\math √ {\maintext and} ∞}). % maintext inside math!

\end{document}





* 위의 소스를 XeLaTeX 으로 컴파일하여 만든 PDF 파일: 




* XeLaTeX 으로 컴파일되는 예제 소스 (section 적용)
  (소스는 반드시 utf-8 인코딩으로 저장되어야 합니다.)

% use article styling for this document

% Modified from: http://wiki.xelatex.org/doku.php?id=basic_document

\documentclass{article}

% enable system font access

\usepackage{fontspec}

% styling: Palatino (main text), Helvetica (stress), Code2000 (exotic text) and Asana Math (for math things)

\setmainfont{Palatino Linotype}

\newfontfamily{\maintext}{Palatino Linotype}

\newfontfamily{\stressed}{Helvetica}

\newfontfamily{\exotic}{Code2000}

\newfontfamily{\math}{Asana Math}

% start of actual document

\begin{document}

\section{XeLaTeX documents}

XeLaTeX documents, which are processed using the {\stressed xelatex} program, use

document source that is in {\stressed UTF-8} encoding, so that you are free to write

in any script that is supported by {\stressed Unicode}.

\section{multilingual text}

Multilingual text is relatively simple in XeLaTeX (when compared to other versions of

TeX), while still leaving you in total control of the styling (compared to word

processing programs like Microsoft Word or OpenOffice Writer)

\subsection{English}

English text is fairly obvious. We pick a main font that supports ascii and we're done!

\subsection{Other languages}

Languages that don't use the "Latin" script are also not a problem, provided we remember to change

to the correct {\stressed font}. For instance, we can write in Korean ({\exotic 한국어}), or in Japanese ({\exotic 日本語}), or in Thai ({\exotic ภาษาไทย}), or in Vietnamese ({\exotic tiếng Việt}), or any other number of languages.

\subsection{Automatic font switching}

XeLaTeX even lets you set up automatic font switching, but it's a bit more work because you need

to tell it which fonts to use for which letters, so most people wouldn't consider it basic functionality.

\section{Sectioning}

We can also section our document so that it's easier for the reader to read through. This document

consists of three sections, of which the second section has three subsections.

\end{document}





* 위의 소스를 XeLaTeX 으로 컴파일하여 만든 PDF 파일: 






Posted by Scripter
,
Posted by Scripter
,

LaTeX 수식에 한글 사용한 예:

|x| = -x \mbox{\ (단, \ \( x \)가 음수일 \ 때)}

* 이 부분은 xmp 태그의 내부에 있습니다. ** 티스토리에서 tex 태그가 있는 문서는 반드시 HTML 모드를 체크한 상태에서 수정한다. (1) tex 태그는 xmp 태그 및 pre 태그와도 호환된다. (2) TeX 의 \mbox 매크로를 쓰면 수식이 아닌 일반 문장으로 해석된다. <strong>strong 태그 안의 글자</strong> <em>em 태그 안의 글자</em> <tex>|x| = -x \mbox{\ if\ $x &lt; 0$}</tex>

  * 이 부분은 pre 태그의 내부에 있습니다.
  ** 티스토리에서 tex 태그가 있는 문서는 반드시 HTML 모드를 체크한 상태에서 수정한다.
  (1) tex 태그는 xmp 태그 및 pre 태그와도 호환된다.
  (2) TeX 의 \mbox 매크로를 쓰면 수식이 아닌 일반 문장으로 해석된다.
                  strong 태그 안의 글자      em 태그 안의 글자 
                  |x| = -x \mbox{\ if\ $x < 0$}




* 이 부분은 xmp 태그의 내부에 있습니다. ** 티스토리에서 tex 태그가 있는 문서는 반드시 HTML 모드를 체크한 상태에서 수정한다. (1) tex 태그는 xmp 태그 및 pre 태그와도 호환된다. xmp 태그로 둘러싸인 내부에서는 모든 태그가 적용되지 않으며, 빈칸과 줄바꿈이 쓰여진 그대로 적용된다, (2) TeX 의 \mbox 매크로를 쓰면 수식이 아닌 일반 문장으로 해석된다. <strong>strong 태그 안의 글자</strong> <em>em 태그 안의 글자</em> <tex>|x| = -x \mbox{\ (단, \ \( x \)가 음수일 \ 때)}</tex>

  * 이 부분은 pre 태그의 내부에 있습니다. pre 태그로 둘러싸인 내부에서는 빈칸과 줄바꿈이 (xmp 로 둘라싸인 내부 처럼) 쓰여진 그대로 적용되나, 태그는 모두 유효하다는 것이 xmp 태그와 다르다.
  ** 티스토리에서 tex 태그가 있는 문서는 반드시 HTML 모드를 체크한 상태에서 수정한다.
  (1) tex 태그는 xmp 태그 및 pre 태그와도 호환된다.
  (2) TeX 의 \mbox 매크로를 쓰면 수식이 아닌 일반 문장으로 해석된다.
                  strong 태그 안의 글자      em 태그 안의 글자 
                  |x| = -x \mbox{\ (단, \ \( x \)가 음수일 \ 때)}



* 한글 레이텍 수식을 포함한 (별도 작성) html 문서 보러 가기




Posted by Scripter
,

(1) MathJax의 사용 예:
\ (a \ne 0\ ) 이면, 2차방정식 \ (ax^2 + bx + c = 0\ ) 의 두 근은 $ $x = {-b \pm \sqrt{b^2-4ac} \over 2a}. $ $
라고 입력하면,
\(a \ne 0\) 이면, 2차방정식 \(ax^2 + bx + c = 0\) 의 두 근은 $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ 로 표시되고,


(2) MathTeX 의 사용 예:
<tex style="border:blue 2px dotted; padding: 3px; background: #ff8;"> \int \ln x \, {\rm d}x = x \ln \ x - x + C </tex>
라고 입력하면,

\int \ln x \, {\rm d}x = x \ln \ x - x + C

로 표시됩니다.


위와 같이 MathJax 와 MathTeX 을 한 페이지 내에서 동시에 사용할 수 있습니다. 그렇게 하기 위해서는 티스토리 블로그 주인장은 관리 모드의 skin.html 의 편집에서 <head> 태그와 </head> 태그 사이에 딱 두 줄

<script type="text/javascript" src="http://www.ezsolver.co.kr/mathjax/v1.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> 



<script type="text/javascript" src="href="http://www.ezsolver.co.kr/mathtex_tag.js"></script>

만 써넣어 주면 됩니다.

※ 인터넷 익스플로러 사용자는 MathJax 를 적용하여 작성된 문서를 볼 때는 디자인 사이언스(Design Science)에서 무료로 배포하는 MathPlayer 플러그인이 설치되어 있어야 볼 수 있습니다.

※ MathJax 는 서버측 CGI 는 전혀 쓰지 않고 오직 Javascript 와 서버에 올려 놓은 폰트 파일들 만으로 동작합니다. MathML 양식의 수식과 LaTeX 양식의 수식을 모두 지원하며 상호 변환도 가능합니다.

※ MathJax 로 작성된 수식은 줌(확대)도 계단 현상이 나타나지 않고 매끄럽게 보이지만, 루트 기호는 좌측 위가 좀 끊어져 보이는 곳이 있습니다. 반면에 MathTeX 으로 작성된 수식은 줌인(확대)하면 계단현상이 나타나 보기게 약간 흉하지만 보통 크기로는 뚜렷하고 예쁩니다. 루트기로 같은 것은 줌인(확대)하더라도 끊어져 보이는 곳이 없습니다.

※ MathJax 양식으로 작성하든 MathTeX 양식으로 작성하든 모바일 기기(아이폰, 갤럭시탭, 아이패드, 갤럭시 패드 등)에서도 수식이 잘 보입니다.

※ MathTeX 은 MimeTeX을 만들었던 가 그 후속 버전으로 만든 순수 C 언어로 작성된 CGI 입니다.  MathTeX 이 하는 일은 서버에 설치된 TeX 시스템을 자동으로 가동시켜 입력된데이터 (URL 파라미터로 서버에 넘어간 문자열)을 이미지(그림) 데이터로 변환한 다음 클라이언트(웹 브라우저)에게 그 이미지의 ContentType 과 함께 보내 주는 역할입니다
.

        [참조]
            ☞ 위의 구조로 작성된 별도의 간단한 문서 보 러 가기
            ☞ MathJax 홈페이지
            ☞ MathPlayer 다운로드와 설치


Posted by Scripter
,
티스토리 편집기의 우측 상단에 있는 HTML 체크박스를 체크하고,

<tex>\frac{\mathrm{d} }{\mathrm{d} } e^x = e^x</tex>

를 입력하면 티스토리 블로그에는 도함수 공식
\frac{\mathrm{d} }{\mathrm{d} x} e^x = e^x
이 표시됩니다.




<tex>\int e^x \, dx = e^x + C</tex>

를 입력하면 티스토리 블로그에는 적분 공식
\int e^x \, dx = e^x + C
가 표시됩니다.


단, 주의 할 것은 수식 부분의 입력과 수정은 반드시 티스토리 편집기의 우측 상단에 있는 HTML 체크박스를 체크하여 HTML 보면서 작업해여 합니다. (편집기에서는 수식을 볼 수 없고 블로그로 가야 수식이 제대로 보입니다.)
왜 그러는지 모르겠지만, 티스토리의 편집기가 소문자 태그 <tex> 와 </tex> 를 대문자 태그 <TEX> 와 </TEX> 로 바꾸어 버리네요. 이것이 조금 불편합니다. (웹 표준에 어긋나는데....)

문장 중에 수식을 포함하기 위해 수식의 크기를 작게 하려면 tex 태그 대신에 stex 태그를 사용하여

<stex>\frac{\mathrm{d} }{\mathrm{d} } e^x = e^x</stex> 와 <stex>\int e^x \, dx = e^x + C</stex>

를 입력하면, 티스토리 블로그에는
\frac{\mathrm{d} }{\mathrm{d} x} e^x = e^x\int e^x \, dx = e^x + C
로 표시됩니다.


※ 위와 같이 티스토리 블로그에 수식이 표현되게 할려면 티스토리 블로그 주인장은 무엇을 해야 할까요? 답은 아주 간단합니다. 스킨 편집에서 HTML/CSS 편집에 가서 <head> 태그와 </head> 태그 사이에 딱 한 줄

<script type="text/javascript" src="http://www.ezsolver.co.kr/mathtex_tag.js"></script>

만 넣어 주면 됩니다.

일반 html 문서에도 (웹서버에 올려진 html 문서이든 로컬에서 작업중인 html 문서이든 상관없이) 저 딱 한 줄만 head 태그 영역 안에 넣어 주면 tex 태그와 stex 태그를 사용할 수 있습니다. 일반 태그처럼 tex 태그와 stex 태그에도 id 명이나 class 명을 옵션으로 줄 수도 있고, 스타일을 적용할 수 있습니다. 또한 tex 태그와 stex 태그는 jQuery 와도 잘 동작합니다. IE6 이상, Safari, FireFox, Chrome 에서도 tex 태그와 stex 태그가 잘 동작함을 확인하였습니다. 모바일 웹에서도 물론 잘 동작합니다.



Posted by Scripter
,