99真人注册平台|欢迎注册

Posts in the “latex” category

LaTeX font example: controlling font colors in Latex documents

LaTeX FAQ: "How do I use font colors in

Defining and using font colors in LaTeX documents turns out to be pretty easy, and it's a great LaTeX feature. Although my choice of colors may leave something to be desired, this example requirements specification was written with LaTeX, and converted to HTML using the latex2html conversion program.

(A really cool thing is that I also generated a LaTeX PDF version of that same requirements specification from the same LaTeX source files. Being able to create a LaTeX HTML document and a LaTeX PDF document from the same LaTeX source is really a terrific feature for technical specifications like this. (Not to mention that you can also keep all your LaTeX source files in a version control system, like CVS or SVN.))

How to define and use LaTeX font colors

In the preamble of your LaTeX document use this tag to include the color package:

\usepackage{color}

Then, when you need to use a different color in your LaTeX document, use a tag like this:

Here's a cool site you should check out:
{\color{blue}{http://www.devdaily.com/}}

A small, complete LaTeX font example document

Oops, I skipped an important part ... earlier in your LaTeX document you need to define what you mean by the color named "blue". A full (but brief) document might look like this:

\documentclass[letterpaper,11pt]{report}
\usepackage{color}
\definecolor{Blue}{rgb}{0.3,0.3,0.9}
\begin{document}

Here's a cool site you should check out:
{\color{Blue}{http://www.devdaily.com/}}

\end{document}

In this LaTeX example I've defined my own color "Blue" with the RGB values shown. Piece of cake ... well, once you know how to do it. ;)

LaTeX: Simple referencing is another reason to use LaTeX for requirements specifications

I've written a lot of use case documents lately for software requirements specifications, and as use cases get more complex, I find the need for "sub use cases" or "alternate scenarios". When referring to these from the main use case (or anywhere else), it's nice to be able to use LaTeX's reference capability.

The LaTeX reference capability lets you refer to one part of a document from another part of the same LaTeX document, and I've found it to be really powerful when creating both PDF and HTML documents from LaTeX code (i.e., LaTeX PDF and LaTeX HTML documents).

LaTeX reference example

Without any further introduction, what I like to do is created a LaTeX document that looks like this:

\documentclass[a4paper,11pt]{article}
\author{Al Alexander}
\title{}

\begin{document}

\section{Main Use Case}

\begin{enumerate}
\item Do something 
\item Do something else
\item Do something more (branch to Sub Use Case (Section ~\ref{label:SubUseCase} on 
      page ~\pageref{label:SubUseCase}))
\item Yada yada yada
\end{enumerate}

\section{Some Other Section}

Note that there might be a lot of other stuff between the reference above and the actual section 
that I'm referring to. So, this is some fluff to simulate that possibility.


\section{\label{label:SubUseCase}Sub Use Case}

\begin{enumerate}
\item Do something 2
\item Do something else 2
\item Do something more 2
\end{enumerate}

\end{document}

This input leads to output that looks like this:

1 Main Use Case
  1. Do something
  2. Do something else
  3. Do something more (branch to Sub Use Case (Section 3 on page 1)
  4. Yada yada yada

2 Some Other Section
  Note that there might be a lot of other stuff between the reference above
  and the actual section that I?m referring to. So, this is some fluff to simulate
  that possibility.

3 Sub Use Case
  1. Do something 2
  2. Do something else 2
  3. Do something more 2b

LaTeX example - discussion

In this case I've simulated what the output looks like (rather than include a PDF document here), but I hope you can see the value of this. Simply stated, it provides a nice linking mechanism from my main use case to a Sub Use Case that is referred to.

This feature/capability is “Reason Number 94” that I use LaTeX to create my PDF and HTML requirements specification documents. :)

LaTeX example document - description lists and tables

Here's a sample LaTeX document where I'm experimenting with newenvironment, a definition list, and tables (the tabular environment. I don't have the output with me at the moment, but I think all of these worked correctly when using pdflatex (LaTeX PDF) and latex2html (LaTeX HTML).

\documentclass[a4paper,11pt]{article}
\author{Al Alexander}
\title{}
\begin{document}
\maketitle
\tableofcontents


% DESCRIPTION TEST

%\newcommand{\entrylabel}[1]{\mbox{\textsf{#1:}}\hfil}
%\newenvironment{entry}
%  {\begin{list}{}%
%     {\renewcommand{\makelabel}{\entrylabel}%
%     \setlength{\labelwidth}{35pt}%
%     \setlength{\leftmargin}{\labelwidth+\labelsep}%
%     }%
%  }%
%  {\end{list}}
  
\newenvironment{deflist}[1][\quad]%
  {\begin{list}{}{%
     \renewcommand{\makelabel}[1]{\textbf{##1}\hfil}%
     \settowidth{\labelwidth}{\textbf{#1}}%
     \setlength{\leftmargin}{\labelwidth+\labelsep}}}
  {\end{list}}

\begin{deflist}
\item[Java]\mbox{}\\A great language for enterprise applications.
\item[Perl]\mbox{}\\A great language for CGI programs and text processing.
\item[C++]\mbox{}\\A difficult but fun language.
\end{deflist}

% TABLE TEST
% WANT TO SEE HOW THIS CONVERTS TO HTML

\begin{tabular}{|l|c|r|}
 \hline
 LANGUAGE & DESCRIPTION & SOMETHING\\
 \hline
 JAVA & A great language for enterprise applications. & R2C3\\
 \hline
 PERL & A great language for CGI programs and text processing. & R3C3\\
 \hline
 C++ & A difficult language. & R4C3\\ 
 \hline
\end{tabular}

\end{document}

LaTeX example: enumerate and itemize line spacing

LaTeX line spacing FAQ: How can I control the line spacing in itemize and enumerate tags?

What I did was to create my own LaTeX command, and then use that command instead of the traditional enumerate tag. (This works just as well for the itemize tag.)

The LaTeX example below shows how to create your own command named packed_enum. After you define this command, just use it instead of enumerate or itemize, and your line spacing will essentially be reduced to single line spacing.

LaTeX multiline comments

I often have a need to create LaTeX comments that span multiple lines. Of course you can create single line comments in LaTeX using the percent character like this:

% this is a comment

But I want to be able to create LaTeX comments that go on for multiple lines. Fortunately, if you know that you're supposed to include the verbatim package, this is pretty easy.

LaTeX multiline comments example

The first step is to include the verbatim package, like this:

LaTeX examples: How to reference a figure or table

LaTeX table/figure FAQ - How do I reference a table or figure in a LaTeX document?

Being able to automatically reference a figure within a LaTeX document is a very cool thing. This referencing capability lets you easily give readers the exact number of a figure, or tell them what page number a figure is located on with the use of a few simple commands (\label, \ref, and \pageref). The same technique works for referencing other objects within a LaTeX document, including tables and equations.

A crazy sed script to convert HTML code to LaTeX

The crazy sed script below is my first attempt at a script that will convert as much HTML as possible to LaTeX. For my purposes I'm mostly interested in tables, lists, buttons, and comboboxes, but I included a few other things as well.

This is in an extremely experimental state, and is included here as much for backup purposes and sharing as anything else.

Here's how you run the sed script on an HTML file named test.html:

sed -f html2latex.sed test.html > test.tex

That being said, here's the current source code for the html2latex.sed file:

LaTeX example - How to create margin notes with LaTeX

The ability to create notes in the margin (also referred to as "margin notes" or "marginal notes") is a really nice/cool feature in LaTeX. In the words of Edward Tufte, it lets you keep your notes near your content, which is a good thing.

Creating the margin notes themselves is very easy. Here's how to create a margin note with the LaTeX \marginpar command:

\marginpar{This note will appear in the margin.}

 

LaTeX example: How to create your own commands with ‘newcommand’

LaTeX question: Can you show a simple example of creating your own LaTeX command?

Here is an example LaTeX file where I'm experimenting with various newcommand and renewcommand capabilities. The file actually contains six LaTeX examples, and in each step I add one more LaTeX feature that is a little harder than the previous step.

Get the LaTeX chapter name and section name on the document header

Wow, this was a tough LaTeX problem, and it would really help if I knew a lot more about LaTeX.

My goal for a LaTeX PDF that I created recently was to get the header of my pages to look something like this:

Section Name (Chapter Name)

where "Section Name" and "Chapter Name" are left-aligned in the header of the page, and would be dynamically replaced by the actual values of the current section and chapter names, respetively.

LaTeX example document using htmlonly, latexonly, and image

Here is some example LaTeX code where I'm experimenting with image inclusion, as well as tags like htmlonly, latexonly, and the alltt environment.

This LaTeX example/test file was created for tests with the pdflatex (LaTeX PDF) and latex2html (LaTeX HTML) utilities. This is definitely not for newbies.

LaTeX strikeout font example - How to use a strikeout/strikethrough font

A LaTeX strikeout font example: It was hard to find out how to use a strikethrough font using LaTeX, and I don't want to lose it, so here's a simple example.

%
% include the "ulem" package in the header
%
\usepackage{ulem}

%
% use the "sout" tag to "strike through" text
%
\sout{Bill Clinton} G.W. Bush is the pres.

Run through the latex2html converter, this produces output text like this:

LaTeX PDF document size/length example

In the example below I'm showing how you can change a bunch of LaTeX document length parameters. The values don't really make any sense -- I've just thrown some numbers in there. I just want to remember how to do this for the next time I need to create a LaTeX PDF document.

(For what I'm trying to achieve today my goal was to get rid of all the margins on the left side of the page. Then I decided to throw in a few other values.)

I found some of these LaTeX examples on pp. 84-89 of The LaTeX Companion.

LaTeX example - Print a chapter or section without a corresponding sectioning number?

LaTeX FAQ: How can I print a chapter or section without a corresponding sectioning number?

Use the * version of the chapter and section commands, like this:

% a sample chapter
\chapter*{Latex FAQs}

% a sample section
\section*{Latex FAQs}

Note that the "normal" way of doing a chapter or section, which would include the correspond chapter or section number, is like this:

% a sample chapter
\chapter{Latex FAQs}

% a sample section
\section{Latex FAQs}

 

LaTeX box - how to create a box

Okay, now I'm getting into the crazy LaTeX code. I'm converting HTML UI prototype images into LaTeX so I can include the prototypes in my Requirements Specification docs.

So, that being my motivation, here's some LaTeX example code that shows how to display the equivalent of a textfield inside of a table. At the very least, this demonstrates how to use the LaTeX fbox command. :)

LaTeX versions - conditionally control your output

The "versions" package (versions.sty) can be very useful in conditionally controlling your output in LaTeX PDF and HTML documents.

LaTeX conditional output

Here's a very simple example of how you can use this package to conditionally control what is output by the LaTeX processor:

LaTeX HTML package - control your output

The LaTeX "html" package (html.sty) can be very useful for the times that you want to conditionally controlling the output in LaTeX documents, but very specifically, when you want one set of output for normal Latex processing (LaTeX PDF output), and another set of output for LaTeX HTML processing.

Here's a very simple example of how you can use this LaTeX HTML package to conditionally control what is output by the LaTeX processor:

99真人注册平台 <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <蜘蛛词>| <文本链> <文本链> <文本链> <文本链> <文本链> <文本链>