- 版面配置中建立一個 HTML/JavaScript 小工具
- 在工具的內容輸入
<style> .post .codeblock { display: block; /* fixes a strange ie margin bug */ font-family: Courier New; font-size: 10pt; overflow:auto; background: #f0f0f0 url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAASwCAYAAAAt7rCDAAAABHNCSVQICAgIfAhkiAAAAQJJREFUeJzt0kEKhDAMBdA4zFmbM+W0upqFOhXrDILwsimFR5pfMrXW5jhZr7PwRlxVX8//jNHrGhExjXzdu9c5IiIz+7iqVmB7Hwp4OMa2nhhwN/PRGEMBh3Zjt6KfpzPztxW9MSAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzB8HS+J9kUTvzEDMwAAAABJRU5ErkJggg==) left top repeat-y; border: 1px solid #ccc; padding: 10px 10px 10px 21px; max-height:1000px; line-height: 1.2em; } </style> <script src="//google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script> - 之後發表的文章中如要輸入程式碼,需先轉換到 HTML 模式,將所要呈現的程式碼放在 <pre class="codeblock prettyprint"> </pre> 之間。
- 如果要顯示的程式碼包含 < 及 > 時,先到這個網頁進入轉碼,再貼到文章裡,或者自己把 < 改成 <,> 改成 >。
2016-03-14
Blogger 加入程式碼區塊
參考網頁:http://pjchender.blogspot.tw/2015/03/blogger.html
2016-03-13
Blogger 輸入 LaTeX 數學式
在版面配置新增一個 HTML/Java 工具,輸入以下代碼後存檔,即可利用 LaTeX 語法打出數學式。
範例:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"> </script>
隨文數式(inline mode)用 $ $, 展式數式(display mode) 用 \[ \]範例:
- 方程式 $ ax^2 + bx + c =0 $ 的公式解為 $ x = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
- \[\sum_{k=0}^{n} \binom{n}{k} = 2^n
\]
LaTeX 畫填充題的答案卷
這是我目前用來畫數學考卷填充題答案卷的 LaTeX 程式碼,解釋其中的參數設定如下:
- 指定為 A4 大小,橫置方向(landscape)
- \firstpageheader{}{}{} 及 \firstpagefooter{}{}{} 用來指定第 1 頁的頁眉及頁足格式。
- \runningheader{}{}{} 及 \runningfooter{}{}{} 用來指定第 2 頁之後的頁眉及頁足格式。
- \extraheadheight{0cm} 指定額外的頁眉高度,\extrafootheight{-1.5cm}表示將頁足下降 1.5 公分,\extrawidth{6cm}表示將內文寬度增加 6 公分。
- \begin{tabularx}{表格寬度}{對齊方式},\textwidth 表內文寬度,此例中分成六欄,其中第六欄用來控制欄高。
- tabularx 表格環境的對齊方式,可使用 X 參數,表示該欄寬度由程度分配。
- \cline{1-5} 表畫一條從第 1 欄到第 5 欄的橫線。
- \rule{寬度}{高度},此處用來畫出一條寬度為 0 公分,高度為 2.4 公分的線,其中 2.4 公分為試誤之後的高度,隨紙張高度而變。
\documentclass[12pt,a4paper,landscape]{exam}
\usepackage{amsmath,amsfonts,amssymb,amsthm,textcomp,gensymb,tabularx,multirow}
\pagestyle{headandfoot}
\firstpageheader{考試日期:}{}{班級:\underline{\hspace{3cm}} 學號:\underline{\hspace{3cm}} 姓名:\underline{\hspace{4cm}}}
\runningheader{考試日期:}{}{班級:\underline{\hspace{3cm}} 學號:\underline{\hspace{3cm}} 姓名:\underline{\hspace{4cm}}}
\firstpagefooter{}{第 1 頁,共 1 頁}{}
\runningfooter{}{第 1 頁,共 1 頁}{}
\extraheadheight{0cm}
\extrafootheight{-1.5cm}
\extrawidth{6cm}
\begin{document}
%空白答案卷
{\noindent 範圍:}\\
{\noindent 說明:請用藍色或黑色墨水筆於答案卷上作答,否則不予計分。請將答案化至最簡並有理化。\\
{\noindent 一、填充題:每格 5 分,共 20 格,共 100 分}\\
\noindent
\begin{tabularx}{\textwidth}{|X|X|X|X|X|c} \cline{1-5}
\centering{1} & \centering{2} & \centering{3} & \centering{4} & \centering{5} &\\ \cline{1-5}
&&&&&\rule{0cm}{2.4cm} \\ \cline{1-5}
\centering{6} & \centering{7} & \centering{8} & \centering{9} & \centering{10} &\\ \cline{1-5}
&&&&&\rule{0cm}{2.4cm} \\ \cline{1-5}
\centering{11}&\centering{12}&\centering{13}&\centering{14}&\centering{15}&\\ \cline{1-5}
&&&&&\rule{0cm}{2.4cm} \\ \cline{1-5}
\centering{16}&\centering{17}&\centering{18}&\centering{19}&\centering{20}& \\ \cline{1-5}
&&&&&\rule{0cm}{2.4cm} \\ \cline{1-5}
\end{tabularx}
\end{document}
2016-03-09
LaTeX 編輯高中數學試卷的預先設定
因為我有編輯數學考卷的需求,所以先把需要用到的設定集中放在同一個檔內,在編輯其他文件時就可直接 input 進去。編輯考卷用的是 exam 這個 document class,也有非常詳盡的使用手冊可以閱讀。大部分內容是參考 David Guo 在 PTT LaTeX 板的分享,小部分修改成個人所需,之後個人需求如有改變會隨時更改。
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{color}
\usepackage{textcomp}
\usepackage{gensymb}
\usepackage{tabularx,multirow}
\usepackage{harpoon}
%設定版面空間大小
%\geometry{a4paper,margin=2cm} %設定使用 A4 紙張,邊界 2cm
%\geometry{bindingoffset=0.5cm} %奇數頁左邊,偶數頁的右邊多出 0.5cm 的裝訂空間
%\geometry{textwidth=,textheight=} 指定內文寬度及高度
% 加這個就可以設定字體
\usepackage{fontspec,indentfirst,xunicode,xltxtra}
% 使用 xeCJK,其他的還有 CJK 或是 xCJK
\usepackage{xeCJK}
% 設定英文字型,不設的話就會使用預設的字型
%\setmainfont{Times New Roman}
% 設定中英文的字型
% 字型的設定可以使用系統內的字型,而不用像以前一樣另外安裝
\setCJKmainfont{教育部標準宋體UN}
%\setCJKmainfont{AR PL UMing TW MBE}
\defaultCJKfontfeatures{AutoFakeBold=6,AutoFakeSlant=.4} %以後不用再設定粗斜
\newCJKfontfamily\Kai{標楷體} %定義指令\Kai則切換成標楷體
\newCJKfontfamily\Hei{微軟正黑體} %定義指令\Hei則切換成正黑體
% 中文自動換行
\XeTeXlinebreaklocale "zh"
% 文字的彈性間距
\XeTeXlinebreakskip = 0pt plus 1pt
% 設定段落之間的距離
\setlength{\parskip}{0.3cm}
% 設定行距
\linespread{1.5}
%段落內縮兩個字
\usepackage{indentfirst}
\setlength{\parindent}{2em}
%選擇題選項編號加上小括號
\renewcommand\choicelabel{(\thechoice)}
%把計分的單位從 point 改為「分」
\pointname{分}
%定義新的大寫羅馬數字指令
\newcommand{\RN}[1]{
\textup{\uppercase\expandafter{\romannumeral#1}}
}
%定義可指定長度之底線指令
\newcommand{\ul}[1]{
\underline{\hspace{#1 cm}}
}
%重新定義子題的編號以整數編號,預設為小寫英文字母
\renewcommand\thepartno{\arabic{partno}}
%將選擇題的正確答案改為粗斜體以及紅字列印
\CorrectChoiceEmphasis{\color{red}\itshape\bfseries}
%設定兩欄的間距
\setlength{\columnsep}{2cm}
%向量符號
\makeatletter
\def\rightharpoonfill@{\arrowfill@\relbar\relbar\rightharpoonup}
\newcommand{\vect}{\mathpalette{\overarrow@\rightharpoonfill@}}
\makeatother
%平行符號
\newcommand{\parallelsum}{\mathbin{\!/\mkern-5mu/\!}}
Overleaf.com 上支援的 CJK 字體列表
Overleaf 是一個線上 LaTeX 服務,其雲端的特性讓使用者可以在各臺電腦上,使用 LaTeX 編輯文件,而不用煩惱各電腦間套件的一致性,以下是 Overleaf 所支援的中日韓(CJK)字型,可於此網頁查到,裡面有我最近喜歡用的教育部標準宋體,該字型是採用標準寫法,對於學習寫字的正確性很有幫助,應該多多推廣讓大家都知道正確的中文字該怎麼寫。
- AR PL Mingti2L Big5 (文鼎PL細上海宋, Chinese traditional)
- AR PL UMing TW (Chinese simplified and traditional)
- AR PL UMing HK (Chinese simplified and traditional)
- AR PL UMing CN (Chinese simplified and traditional)
The above 3 seems to have no difference. - AR PL UKai TW (Chinese simplified and traditional)
- AR PL UKai HK (Chinese simplified and traditional)
- AR PL UKai CN (Chinese simplified and traditional)
The above 3 seems to have no difference. - AR PL SungtiL GB (文鼎PL简报宋, Chinese simplified)
- AR PL KaitiM GB (文鼎PL简中楷, Chinese simplified)
- AR PL KaitiM Big5 (文鼎PL中楷, Chinese traditional)
- cwTeXKai (楷書, Chinese traditional, Korean)
- cwTeXMing (明體, Chinese traditional, Korean)
- cwTeXHeiBold (粗黑體, Chinese traditional, Korean)
- cwTeXFangSong (仿宋體, Chinese traditional)
- cwTeXYen (圓體, Chinese traditional)
- Droid Sans Fallback (Chinese, Japanese)
- IPAGothic (IPAゴシック, Japanese)
- IPAexGothic (IPAexゴシック, Japanese)
- IPAPGothic (IPA Pゴシック, Japanese)
- IPAMincho (IPA明朝, Japanese)
- IPAexMincho (IPAex明朝, Japanese)
- IPAPMincho (IPA P明朝, Japanese)
- MOESongUN (教育部標準宋體UN, Chinese traditional)
- TW-Sung (全字庫正宋體, Chinese simplified and traditional)
- TW-Kai (全字庫正楷體, Chinese simplified and traditional)
- TW-MOE-Std-Kai (教育部標準楷書, Chinese traditional)
- WenQuanYi Micro Hei (文泉驿微米黑, CJK)
- WenQuanYi Zen Hei (文泉驿正黑, CJK)
- WenQuanYi Zen Hei Sharp (文泉驿点阵正黑, CJK)
- WenQuanYi Micro Hei Mono (文泉驿等宽微米黑, CJK)
- Droid Sans Japanese (Japanese)
2009-11-09
《次世代 Linux – Ubuntu 玩全手冊》電子版免費下載
著名的 Ubuntu 書籍《次世代 Linux – Ubuntu 玩全手冊》,在和出版社的合約到期後,作者蔡東邦先生大方地把電子版公佈在網路上,電子版的連結就在蔡先生部落格的文章《次世代 Linux – Ubuntu 玩全手冊 (PDF 線上完整版)》中。
這本書雖然是 2006 年底出版,以 Ubuntu Linux 6.10 為主要的 distro.,但許多觀念和做法仍是一脈相通的,是市面上少數以 Ubuntu 為主且以輕鬆文句敘述的好書,下一版將配合 Ubuntu Linux 10.04 LTS - Lucid Lynx,期待第二版的出版。
以下是電子版的連結,摘自蔡東邦先生的網站:
《次世代 Linux-Ubuntu 玩全手冊》 in PDF (國內)
《次世代 Linux-Ubuntu 玩全手冊》 in PDF (國外)
這本書雖然是 2006 年底出版,以 Ubuntu Linux 6.10 為主要的 distro.,但許多觀念和做法仍是一脈相通的,是市面上少數以 Ubuntu 為主且以輕鬆文句敘述的好書,下一版將配合 Ubuntu Linux 10.04 LTS - Lucid Lynx,期待第二版的出版。
以下是電子版的連結,摘自蔡東邦先生的網站:
《次世代 Linux-Ubuntu 玩全手冊》 in PDF (國內)
《次世代 Linux-Ubuntu 玩全手冊》 in PDF (國外)
2008-06-17
Google Toolbar for Firefox 3 is ready!
cookeyholder 覺得 Firefox 最重要的 extension 就是 Google Toolbar。
之前升級到 Ubuntu 8.04 時,Firefox 也跟換成了 Firefox 3 beta5,可是一堆 extension 也跟著失效了,尤其是 Google Toolbar 也在失效之列,讓 cookeyholder 在搜尋東西的時候總要多花一些手腳,現在 Google Toolbar 已經正式支援 Firefox 3 了,像 cookeyholder 一樣想念它的人趕快去安裝吧。
之前升級到 Ubuntu 8.04 時,Firefox 也跟換成了 Firefox 3 beta5,可是一堆 extension 也跟著失效了,尤其是 Google Toolbar 也在失效之列,讓 cookeyholder 在搜尋東西的時候總要多花一些手腳,現在 Google Toolbar 已經正式支援 Firefox 3 了,像 cookeyholder 一樣想念它的人趕快去安裝吧。
2008-06-12
利用 OpenOffice.org 在 Command Line 把 DOC 檔轉成 PDF 檔
這是利用 OpenOffice.org 的巨集來把 DOC 檔轉成 PDF 檔的方法,好處是也可以用在 shell script 裡,一次把好幾個檔案轉成 PDF 檔,做法及用法如下:
撰寫 OpenOffice.org 的巨集:
參考文章:
撰寫 OpenOffice.org 的巨集:
- 打開 OOWriter,點選工具列上的「工具」/「巨集」/「組織巨集」/「OpenOffice.org Basic」
- 有巨集來源那邊點選「我的巨集」下的「Standard」/「Module1」,再點一下右邊的編輯來編輯 Module
- 之後會跳出一個視窗,在視窗內輸入以下的 code 後存檔就可以把 OpenOffice.org 關掉了。
REM ***** BASIC *****
Sub ConvertWordToPDF(cFile)
cURL = ConvertToURL(cFile)
' Open the document.
' Just blindly assume that the document is of a type that OOo will
' correctly recognize and open -- without specifying an import filter.
oDoc = StarDesktop.loadComponentFromURL(cURL, "_blank", 0, Array(MakePropertyValue("Hidden", True), ))
cFile = Left(cFile, Len(cFile) - 4) + ".pdf"
cURL = ConvertToURL(cFile)
' Save the document using a filter.
oDoc.storeToURL(cURL, Array(MakePropertyValue("FilterName", "writer_pdf_Export"), ))
oDoc.close(True)
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
- 把下列 code 存成 shell script,檔名可以取成 doc2pdf。
#!/bin/sh
DIR=$(pwd)
DOC=$DIR/$1
/usr/bin/oowriter -invisible "macro:///Standard.Module1.ConvertWordToPDF($DOC)" - 加上執行的權限
sudo chmod +x doc2pdf
- 移到 /usr/local/bin
sudo mv doc2pdf /usr/local/bin
在 Command Line 輸入 doc2pdf test.doc 就會輸出 test.pdf 了
參考文章:
Convert MS/Word to PDF
訂閱:
文章 (Atom)
