LaTeX笔记(1)

取消连字符
\sloppy: 弱命令
效果不是很明显,但是基本保证布局美观

\pretolerance=10000: 强命令
效果很明显,几乎可以去掉所有连字符,但是对布局影响很大
10000是一个阈值,可以适当变小,可能会有比较折中的效果
补救措施:在字符间距非常大的地方用 \- 命令强制生成连字符

引号
` ` : 左双引号(两个小撇,和波浪号同一个键)
` : 左单引号(一个小撇,同上)
‘ ‘ : 右双引号(两个单引号)
‘ : 右单引号(一个单引号)
P.S.请不要直接复制粘贴,中间有空格,为了HTML下的显示需要

强制不分行
\mbox{content here will not be split up}

四级标题
\section{}
\subsection{}
\subsubsection{}
\paragraph{*.*.*.* }

波浪线
\~{}

上角标
\textsuper{}: 非数学环境
^{}: 数学环境

首段缩进(默认不缩进)
\usepackage{indentfirst}

推荐的格式设置
\documentclass[a4paper,12pt]{article}: 纸张类型,主体字号,文档类型
\usepackage[top=1in,bottom=1in,left=1.25in,right=1.25in]{geometry}: 页边距

简历模板

http://www.ctan.org/tex-archive/macros/latex/contrib/tucv

超链接去边框和颜色
\usepackage[colorlinks,allcolors=black]{hyperref}

嵌入所有字体
dvips -Pdownload35 inputfilename.dvi

Android平台下FreePascal的交叉编译器

0) Preface
0.1) The Operating System is Ubuntu 10.10
0.2) All the softwares are the latest stable version by April 12, 2011

1) Download the Source of Free Pascal Compiler
The ‘fpc-2.4.2.source.tar.gz’ on http://sourceforge.net/projects/freepascal/files/Source/2.4.2/

2) Install the fpc-source. Just extract it.
The root folder of fpc-source for me is ‘/home/victorhu/fpc-source’

3) Download the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)
The ‘IA32 GNU/Linux Installer’ on http://www.codesourcery.com/sgpp/lite/arm/portal/release1600

4) Install the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)
The installation need the system shell to be bash not dash which is default for Ubuntu. So
4.1)

sudo dpkg-reconfigure -plow dash

Choose NO to make the bash as the system shell.
4.2) Goto the root folder of Arm-Eabi for me is ‘/home/victorhu/toolchain/’
4.3)

chmod +x arm-2010.09-05-arm-none-linux-gnueabi.bin

4.4)

./arm-2010.09-05-arm-none-linux-gnueabi.bin

5) Get the Cross Compiler
5.1) Goto the root folder of fpc-source
5.2)

make crossall CPU_TARGET=arm OS_TARGET=linux OPT="-dFPC_ARMEL -O- -gl"  CROSSPORT="-O-" CROSSBINDIR=/home/victorhu/toolchain/arm-none-linux-gnueabi/bin

5.3) The ‘ppcrossarm’ under ‘/home/victorhu/fpc-source/compilers/’ is just what we want.
Note: CROSSBINDIR is depend on the folder of Arm-Eabi.

6) Write a Hello Word in Pascal
The path for me is /home/victorhu/hello.pas

Program hello;
begin
writeln('Hello World!');
end.

7) Compile the Hello World in Pascal via CrossCompile Environment.
7.1) Goto the folder contains ‘ppcrossarm’
7.2)

./ppcrossarm -Tlinux -O- -XP -Fu/home/victorhu/fpc-source/rtl/units/arm-linux/ -FD/home/victorhu/toolchain/arm-none-linux-gnueabi/bin /home/victorhu/hello.pas

Note: -Fu is the unit path, -FD is the compiler utilities path.
7.3) The ‘hello’ under ‘/home/victorhu/temp’ is just the what we want (not hello.pas).

8) Test the Crosscompiled Hello World in Android Emulator
8.1) the tools under Android SDK or the ADT of Eclipse is where we can find it.
8.2) Goto the adb root folder under Android SDK .
It’s ‘platform-tools’ under the main root folder of Android SDK now while it’s ‘tools’ before.
8.3) Test whether is device is connected.

./adb devices

If it shows somthing like ‘Emulator-5544 device’ (for me), then it’s right.
8.4) Push the program into Android Emulator.

./adb push ~/hello /data/hello

8.5) Run the program on the Android Emulator.

./adb shell data/hello

If it shows ‘Hello World!’ (the result of the original program), then everything is done now!

9) Reference
9.1) http://alexmogurenko.com/blog/programming/android-building-free-pascal-compiler-for-android/
9.2) http://wiki.freepascal.org/Android_Interface
9.3) http://wiki.freepascal.org/Setup_Cross_Compile_For_ARM

P.S.本文参与“第二届 Google 暑期大学生博客分享大赛 – 2011 Android 成长篇”,感谢大家支持

Ubuntu 10.04安装Android开发环境(更新解决WST包缺少问题)

更新:在10.10及11.04中搭建时可能会遇到WST包缺少的问题,可以参照这篇日志解决

注:本文中<android_sdk>代表Android SDK安装路径
这里选择”/home/victorhu/Code/android-sdk-linux_86″

Step 0 : 准备

sudo apt-get update

Step 1 : 安装 Java JDK & Eclipse

sudo apt-get install sun-java6-jdk eclipse

Step 2 : 安装 Andorid SDK Starter Package

wget http://dl.google.com/android/android-sdk_r06-linux_86.tgz
tar -zxvf android-sdk_r06-linux_86.tgz

你可以把这个文件放在任意你希望的位置,这就是Andord SDK的安装位置

Step 3 : 配置环境

export PATH=${PATH}:<android_sdk>/tools

如运行时出现”The project cannot be built until build path errors are resolved”错误,请检查此步

Setp 4 : 安装 ADT Plugin for Eclipse
在Eclipse中选择”Help” –> “Install New Software”将出现类似下方画面
1
在”Work with”区域填上”https://dl-ssl.google.com/android/eclipse/”然后选择”Add”
此时会显示类似上方的画面,勾选”Develop Tools”点击”Next”,剩余步骤同一般程序安装
更新:如果此处遇到WST包缺少的问题,可以参照这篇日志解决
(可能会遇到证书错误,选择继续安装即可)

Step 5 : 配置 SDK
在Eclipse中选择”Windows” –> “Preferences”,然后在左侧选择”Android”可得到类似下方画面
2
点击”Browse”选择Android SDK安装路径,此时会在”SDK Location”处显示,点击”Apply”使配置生效

Step 6 : 下载 SDK package
在Eclipse中选择”Windows” –> “Android SDK and AVD manager”,在左侧选择”Available”
选择所有(如下图所示),然后开始安装”Install Selected”
3
附两张过程中的截图: 1、选择”Accept All”比较方便; 2、下载可能需要花费比较长的时间
4

5

至此,Andorid的开发环境安装成功

Step 7 : 导入Sample
1、新建工程,选择”Android Project”(如下图)
6
2、在”Contents”中选择”Create project from existing source”,
在”Location”中选择Samples的文件夹,这里选择”<android_sdk>/samples/android-7/Home”
在”Build Target”中选择开发平台,这里选择”Android 2.2″(截图如下)
7

Step 8 : 新建AVD(Android Virtual Device)
在Eclipse中选择”Windows” –> “Android SDK and AVD manager”,在左侧选择”Virtual Devices”,然后选择右侧的”New”(截图如下)
8
相关设置:
1、Name,任意但有限制,不可以有空格、点等一些特殊字符
2、Target,需要和刚才选择的”Build Target”一致
3、SD Card,设定给Android分配的SD卡内存容量,这里选择1G(1024MB)
其他的默认即可(截图如下)
9

Step 9 : 运行
找到运行按钮,或者直接Ctrl+F11,稍微等待一下编译过程,然后即可出现Android的运行界面,附截图两枚
10

11

至此,所有工作基本完成,有了Documentation、Samples,Android的大门已经打开了!

参考资料:
1、Installing the SDK | Android Developers
2、《
Android应用程序开发