2017-11-19

啟用 dnf 的 fastestmirror 功能,使用回應最快之鏡像站

  1. 修改 /etc/dnf/dnf.conf 加入 fastestmirror=true
  2. sudo dnf update

參考資料:
dnf 最快鏡像站
https://fedora-tw.org/t/dnf/134

Linux 與 Windows 之時間設定不同的解決方式

Linux 和 Windows 對硬體時間的認定不同,Windows 是將 BIOS 時間當成是本地時間,而 Linux 則是當成 UTC+0 時間,所以如果同時灌雙系統的話,在切換時系統時就會發現時間差了 8 小時左右,為了解決這個現象,不外乎調整 Linux 設定使之使用本地時間,或者調整 Windows 改用 UTC 時間。

解法一:讓 Linux 使用本地時間
sudo timedatectl set-local-rtc 1 --adjust-system-clock
命令最後面的 1 表示 YES,要使用本地時間;如果改為 0 就表示 NO,要使用 UTC 時間。

檢查是否生效,如果生效就會顯示「RTC in local TZ: yes」
timedatectl | grep local


解法二:讓 Windows 使用 UTC 時間
  1. 先在 Linux 裡設定使用 UTC 時間
  2. sudo timedatectl set-local-rtc 0
  3. 修改 Windows 登錄機碼
    1. 找到 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation 
    2. 新增一個 DWORD(32-位元) 值,並命名為「RealTimeIsUniversal」,將其值設為 1
  4. 或者是在命令提示字元(CMD) 裡輸入以下指令
  5. Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1
  6. 如果是 64 位元 Windows 則將其中的 DWORD 改為 QWORD
  7. Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_QWORD /d 1
  8. 重開機後即完成設定

參考資料:
How to Fix Time Differences in Ubuntu 16.04 & Windows 10 Dual Boot
http://ubuntuhandbook.org/index.php/2016/05/time-differences-ubuntu-1604-windows-10/

2017-11-12

Fedora 27 安裝 Fcitx 及嘸蝦米

最近重灌 Linux 系統,從 Ubuntu 跳到 Fedora,整個安裝的過程給我一種安心的感覺,原先是安裝 Fedora 26,後來發現 Fedora 27 過幾天就要 release 了,沒考慮多久就先升到 Fedora 27 beta。

預設的輸入法框架是 ibus,照網路上的教學安裝好嘸蝦米輸入法以後,發現打不出「只」這個字,而且實在不習慣按 Shift 切換中英文輸入法,還是習慣 ctrl+space 切換,弄了很久沒弄好乾脆把輸入法框架換成 Fcitx,沒多久就有順手的嘸蝦米可以用了,稍微整理一下整個過程,避免以後忘記。

  1. 移除 ibus
    sudo dnf remove ibus
  2. 安裝 fcitx
    sudo dnf install fcitx fcitx-table-chinese fcitx-configtool fcitx-qt4 fcitx-chewing fcitx-table-extra im-chooser
  3. 指定輸入法(不確定要不要這個步驟,每次都出現錯誤訊息)
    gsettings set org.gnome.settings-daemon.plugins.keyboard active false
  4.  查看輸入法目前的狀態
    imsettings-info
    應該要下面這樣
    Xinput file: /etc/X11/xinit/xinput.d/fcitx.conf
    GTK+ immodule: fcitx
    Qt immodule: fcitx
    XMODIFIERS: @im=fcitx
    XIM server: /usr/bin/fcitx -D
    Preferences: /usr/bin/fcitx-configtool
    Auxiliary:
    Short Description: FCITX
    Long Description:
    Icon file: /usr/share/pixmaps/fcitx.png
    Is system default: TRUE
    Is user default: TRUE
    Is XIM server: FALSE
  5. 修改 bash 環境,在 $HOME/.bashrc 中加入下列三行
    export GTK_IM_MODULE=fcitx
    export QT_IM_MODULE=fcitx
    export XMODIFIERS="@im=fcitx"
    
  6. 用 im-chooser 來選擇 fcitx
  7. 到 fcitx 設定加入嘸蝦米輸入法


參考資料:
我的 fedora 調校手冊
http://blog.wildsky.cc/posts/tune-my-fedora/

[Linux][Fedora] Fedora 20 上面安裝 fcitx
http://lihomo.blogspot.tw/2014/06/linuxfedora-fedora-20-fcitx.html

Fcitx 輸入法使用教學
https://chakra-zh.blogspot.tw/2015/10/fcitx.html

2016-03-14

Blogger 加入程式碼區塊

參考網頁:http://pjchender.blogspot.tw/2015/03/blogger.html

  1. 版面配置中建立一個 HTML/JavaScript 小工具
  2. 在工具的內容輸入
    <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>
    
  3. 之後發表的文章中如要輸入程式碼,需先轉換到 HTML 模式,將所要呈現的程式碼放在 <pre class="codeblock prettyprint">  </pre> 之間。
  4. 如果要顯示的程式碼包含 < 及 > 時,先到這個網頁進入轉碼,再貼到文章裡,或者自己把 < 改成 &lt;,> 改成 &gt;。

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) 用 \[ \]

範例:
  1. 方程式 $ ax^2 + bx + c =0 $ 的公式解為 $ x = \dfrac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
  2. \[\sum_{k=0}^{n} \binom{n}{k} = 2^n
    \]

LaTeX 畫填充題的答案卷


這是我目前用來畫數學考卷填充題答案卷的 LaTeX 程式碼,解釋其中的參數設定如下:
  1. 指定為 A4 大小,橫置方向(landscape) 
  2. \firstpageheader{}{}{} 及 \firstpagefooter{}{}{} 用來指定第 1 頁的頁眉及頁足格式。
  3. \runningheader{}{}{} 及 \runningfooter{}{}{} 用來指定第 2 頁之後的頁眉及頁足格式。
  4. \extraheadheight{0cm} 指定額外的頁眉高度,\extrafootheight{-1.5cm}表示將頁足下降 1.5 公分,\extrawidth{6cm}表示將內文寬度增加 6 公分。
  5. \begin{tabularx}{表格寬度}{對齊方式},\textwidth 表內文寬度,此例中分成六欄,其中第六欄用來控制欄高。
  6. tabularx 表格環境的對齊方式,可使用 X 參數,表示該欄寬度由程度分配。
  7. \cline{1-5} 表畫一條從第 1 欄到第 5 欄的橫線。
  8. \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)