The KFormula Users Manual

The KFormula Users Manual

The KFormula Users Manual

Jonathan Drews <j.e.drews@att.net>

Developer: Ulrich Küttler


Revision 0.00.02

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

KFormula is used to layout formulas.


Chapter 1. Introduction

Introduction

Chapter 1. Introduction

KFormula is used to write formulas. It doesn't evaluate anything. All it does is print them.

KFormula was designed for your editing pleasure. It makes it delightful to enter Greek letters, fractions and all the stuff that makes a formula look like a formula.

But most of the time you won't want to use KFormula itself. Instead you might choose to use it from within KWord or any other KOffice application. That is KFormula is not a useful application on its own but an extension to all the other KOffice applications you've fallen in love with.

Where ever KFormula gets embedded, it will behave the same.

KDE Logo
Chapter 2. Basics

Basics

Chapter 2. Basics

A new (empty) KFormula document looks like a small blue square. This square stands for the central idea of KFormula. It represents an empty list. The idea of KFormula is to have different elements arranged in lists. An element in this respect might be a single char or a root symbol or something like that. The lists are put together so that they form a formula. That is there are lists for indexes, lower and upper bounds and so on. And of course there is the main list, which we've already seen.

Writing a formula means to fill the empty list with letters, figures and mathematical symbols. That is straightforward: use your keyboard. As soon as you type something the “empty” symbol will vanish and you will see whatever you have inserted instead. New characters are always put at the current cursor position.

There is a toolbar called Add that allows you to create more complex elements. There are indices, fractions, roots and matrices to name a few. All these elements consist of at least one list, you can move the cursor into and insert new items.

KDE Logo
Chapter 3. Using KFormula

Using KFormula

Chapter 3. Using KFormula

Below is a typical formula entry in KFormula. To enter the partial derivatives and Greek letters click on the symbol combo box, on the right, and select the appropriate symbol. The symbol combo box, in the figure below, has the word “Cap” on it. Click on the return key symbol to the right of it, to enter a symbol.


Screenshot of KFormula

The Greens formula above can be printed to a PostScript® file. To do that choose File->Print and configure print as shown below:


Here's a screenshot of Greens Formula in KFormula

Here is what the the resulting PostScript® file should look like:



Important

See the Mathematical Fonts section for font installation details. You must install the esstix fonts to get these results

More KFormula features

More on formulas

To enter matrices, click on the [ ] and then click on the matrix symbol . You can move from matrix element to matrix element using the arrow keys Right arrow, Up arrow, Down arrow and Left arrow. An example matrix is shown below.



KDE Logo
Chapter 4. Command Reference

Command Reference

Chapter 4. Command Reference

The main KFormula window

The File Menu

File->New (Ctrl+N)

Creates a new KFormula document

File->Open (Ctrl+O)

Opens a previously saved document

File->Open Recent

displays a selection of recently saved documents you can open

File->Save (Ctrl+S)

Saves the document

File->Save As

Saves the document with a name you provide

File->Print (Ctrl+P)

Prints the document

File->Print Preview...

Shows how the printed document will appear

File->Document Information...

Provides a dialog box where you can enter your name, e-mail address and a short description about the document

File->Send File...

Invokes Kmail so you can e-mail the file. Note: You still have to attach the file to the e-mail

File->Close (Ctrl+W)

Closes the current document

File->Quit (Ctrl+Q)

Quits KFormula

The Edit Menu

Edit->Undo (Ctrl+Z)

Undoes an action. You can revert to the state that existed before your last change

Edit->Redo (Ctrl+Shift+Z)

Undoes an undo. Reverse the action of Undo. This will restore the change you originally made

Edit->Cut (Ctrl+X)

Cuts a highlighted piece of text from the KFormula screen.

Edit->Cut (Ctrl+C)

Copies a highlighted piece of text from the KFormula screen.

Edit->Paste (Ctrl+V)

Pastes the text you selected with Cut or Copy to the KFormula screen.

Edit->Select All (Ctrl+A)

Highlights all the text in the KFormula screen for either Cut or Copy.

Edit->Remove enclosing element (Ctrl+R)

Removes enclosing braces, brackets or absolute value bars. This action takes place on the braces just outside the cursor.

Edit->Convert to Greek (Ctrl+G)

Converts a Latin character to a Greek symbol.

Edit->Edit Formula String

Brings up an editor where you can edit the existing formula.

See the Advanced editing section for details.

The Element Menu

Element->Add...->Add root (Ctrl+2)

Inserts the square root.

Element->Add...->Add fraction (Ctrl+3)

Inserts a fraction.

Element->Add...->Add bracket

Inserts a pair of brackets, i.e. ( ). You can also just type ( to insert a pair of brackets.

Element->Add...->Add fraction (Ctrl+3)

Inserts a fraction.

Element->Add...->Add integral (Ctrl+6)

Inserts the integral sign.

Element->Add...->Add sum (Ctrl+7)

Inserts the summation sign (sigma).

Element->Add...->Add prod (Ctrl+4)

Inserts the product sign.

Element->Add...->Add matrix (Ctrl+8)

Inserts a matrix. A dialog box pops up, with the default size being 3x3. You can specify the number of rows and columns in this box.

Element->Add...->Add 1x2 matrix

Inserts a two rowed column vector.

Element->Add...->Add upper index (Ctrl+U)

Adds an upper index like so:

Element->Add...->Add lower index (Ctrl+L)

Adds a lower index:

Note

See the Definite Integrals and Indices section for details about indices.

Element->Add...->Add thin space

Inserts a small space.

Element->Add...->Add medium space

Inserts a space that is one and a half times wider.

Element->Add...->Add thick space

Inserts a double space.

Element->Add...->Add quad space

Inserts a quadruple wide space.

Element->Matrix->Insert Column

Inserts a column in an existing matrix. The column is inserted where the cursor is at.

Element->Matrix->Append Column

Appends a column to an existing matrix. The column is appended on the right.

Element->Matrix->Remove Column

Removes a column from an existing matrix. Removal occurs where the cursor is positioned.

Element->Matrix->Insert Row

Inserts a row in an existing matrix. The row is inserted where the cursor is at.

Element->Matrix->Append Row

Appends a row to an existing matrix. The row is appended on the bottom.

Element->Matrix->Remove Row

Removes a row from an existing matrix. Removal occurs where the cursor is positioned.

Element->Left delimiter

Allows insertion of various delimiters i.e. (, {, and [.

Element->Right delimiter

Allows insertion of various delimiters i.e. ), }, and ].

Element->Insert symbol (Ctrl+I)

Inserts the symbol, selected in the symbol toolbar.

The Settings Menu

Here you can choose how KFormula is configured. You can select the toolbars you want displayed or the type of fonts to be used.

Settings->Syntax highlighting

Checking this item determines if the numbers will be displayed in color

Settings->Show file toolbar

Toggles the toolbar that contains clickable icons for new, open and save files. Print and print preview are here also.

Settings->Show edit toolbar

Toggles the edit toolbar.Here are clickable icons for cut and paste as well as Undo and Redo.

Settings->Show add toolbar

This toolbar contains all the mathematical elements such as Sum, Integral, Exponent etc..

Settings->Show symbol toolbar

This toggles the combo box that contains Del, the partial derivative symbol, limit arrows, boolean operators and other mathematical symbols.

Settings->Show matrix toolbar

This toggles the matrix toolbar. It contains clickable icons that pertain to matrix creation and editing.

Configuring Shortcuts

The Settings->Configure Shortcuts... allows you to specify key bindings

Below is an example of how to configure a short cut for making a thick space.



  • Click on the custom button.

  • Next click on the primary button.

  • Do CTRL Space and the dialog should disappear. The keybinding is now entered.



Pressing the keys CTRL Space now produces a thick space.

Configuring Toolbars

The Settings->Configure Toolbars... Is used to add additional buttons to the toolbars.



  • To add a button to the File toolbar,



    make sure File <KOfficeShell> is displayed in the top combo box.

  • Click on one of the items in the left hand pane. This item will now have a blue background showing that it has been selected.

  • Next click on the Right arrow button to place it in the right pane.

  • Click on Apply and then click on OK

The new Item should be in the toolbar.

Configuring KFormula

The Settings->Configure KFormula... is where the font sizes are selected and additional fonts are installed.

  • The Formula section allows you to select fonts and font highlight colors.

  • The Fonts section allows you to install additional fonts. See the Additional Math Fonts section.

The Help Menu

Help->KFormula Handbook (F1)

Invokes the KDE Help system starting at the KFormula help pages. (this document).

Help->What's This? (Shift+F1)

Changes the mouse cursor to a combination arrow and question mark. Clicking on items within KFormula will open a help window (if one exists for the particular item) explaining the item's function.

Help->Report Bug...

Opens the Bug report dialog where you can report a bug or request a “wishlist” feature.

Help->About KFormula

This will display version and author information.

Help->About KDE

This displays the KDE version and other basic information.

KDE Logo
Chapter 5. Advanced Editing

Advanced Editing

Chapter 5. Advanced Editing

Name insertion

A special feature is the name insertion. The blue square you type into is actual a list. Furthermore, that list can contain other lists. When you type a backslash (\) you get a new empty list right away. But this one is special. It uses a different font and is meant to insert things like function names. There is, however, a second idea here. Your keyboard only has a limited number of keys. The wealth of mathematical symbols on the other side is overwhelming. To get one of those you can type its name and press the space key afterwards. The name you typed will be replaced by the symbol then. In this context, the Space key means “get out of here”, that is move the cursor to the containing list. The cursor will be positioned at the end of what you just entered but will also enclose part of the original formula, after pressing the space bar.

Another thing you might want to insert are spaces. We all know, printing formulae is all about the right spacing. And you can do just that using a “name list”.

Inside the blue square do: \ , SPACE to get a small space.

Do: \ < Space to get a medium space.

Do: \ ; Space to get a thick space.

Do: \ quad Space to get a quadruple wide space.

In the same way, specific mathematical symbols can be inserted. \ oint Space inserts the path integral about a closed contour. Below is the result of \ oint Space:



Editing Formulas

Editing Formulas

Editing Formulas

The Edit->Edit Formula String allows the user to edit the ASCII formulas that have been copied from other applications, such as Scilab, and transform them directly into mathematical type. An example will make this clear. Below is a screenshot of INRIA Scilab.



Copy and paste the text beginning with x*sin(30*x) into the formula editor as shown below:



If you click on OK, the editor will complain about aborted parsing. It cannot recognize one of the symbols in the formula. The displayed formula would show that the Pi symbol is not correctly rendered. This means that the % must be deleted. Do this and KFormula will render the mathematical font properly, as shown below.



The formula editor will accept most C language mathematical expressions, like the formulas from a Runge-Kutta program below:

void derivs(float x, float y[], float dydx[])
{
 dydx[1] = y[2];
 dydx[2] = -0.8*x*y[2] - sin(x)*y[1];
}

Here dydx[1] is the first order derivative and dydx[2] is the second order derivative. After copying the formula, you will have to edit the derivatives with KFormula. Here is how it is done. First copy and paste the bottom expression into the formula editor.



Next remove the [ ], leaving just y's.



Now click OK and place the cursor by a y and delete it. Insert the appropriate symbols as shown below.



Not every expression that KFormula is capable of translates into a valid C expression. For example the superscript expression:



is displayed as ()**(), which is not a valid C statement for exponentiation. Similarly the 1 by 2 matrix displays as ()/(). This is not a valid array in C.

KDE Logo
Definite Integrals and Indices

Definite Integrals and Indices

Definite Integrals and Indices

Definite Integrals

A definite integral is made by using Ctrl+U for the upper limit of integration and Ctrl+L for the lower limit of integration.



Reposition the cursor in front of the integral after making the first of the limits.

Positioning Indices

The upper or lower index can be positioned by highlighting the desired text. In this example, an arrow is needed above the P, in dP. Using Ctrl+U places the desired vector symbol in the wrong place; namely above the “d”.

The problem is solved by highlighting only the P in and then entering Ctrl+U. Here is the correct result.

KDE Logo
KDE Logo
Chapter 6. Mathematical Fonts

Mathematical Fonts

Chapter 6. Mathematical Fonts

In order to print postscript files from KFormula, you need to get the esstix fonts. These fonts can be obtained from ftp://ftp.elsevier.nl/pub/styles/esstix/esstix.zip

Installing the fonts with KControl

After downloading the fonts, install them into a folder called esstix. You can unpack them with the KDE application Ark. Right click on esstix.zip and select Extract here.... Then start the KDE font installer by going to the K menu and selecting the command Control Center->System-> Font Installer You should get the following screen:


Picture of the KDE font installer

You will need to run the font installer with root privileges. Click on the button Administrator Mode and enter your root password. Click on the button Change Folder. This should bring up a pane from where you can select the folder your fonts are stored in. In this example they are stored in /home/poincare/esstix.


Picture of the KDE font installer

Click on the the folder esstix and then click on the OK button. You should obtain the following result.


Picture of font installer ready to 
install

Click on the top font entry. Holding down the Shift key, click on the last esstix font, at the bottom. Your selection should look like this.


Picture of the font installer 
installing

You should use the native AFM files. Set up your Settings->System as shown below. The Generate AFM's, with box should be unchecked:


Picture of settings tab

Return to the Fonts tab. Click on the Install button. The fonts will install. After this you must click on the Apply button. the following splash will appear:


Picture of KControl applying the 
fonts

Answer Yes to the Apply system changes now dialog. You are done installing the esstix fonts.

Additional Math Fonts

Additional Math Fonts

Additional Math Fonts

Additional math fonts can be installed with Settings->Configure Kformula... Math Fonts



First install the desired fonts with the Font Installer, in KControl. This will make them available to your computer. Next enter the Math Fonts section and add them using the Right arrow, as shown above. The Euclid Symbol fonts, that were added above, are now available in the Insert Symbol combo box.

KDE Logo
KDE Logo
Chapter 7. Credits and Licenses

Credits and Licenses

Chapter 7. Credits and Licenses

KFormula copyright Ulrich Küttler

Co-developer: Andrea Rizzi

Documentation copyright 2002 Jonathan Drews <j.e.drews@att.net>

This documentation is licensed under the terms of the GNU Free Documentation License.

This program is licensed under the terms of the GNU General Public License.

KDE Logo
Appendix A. Installation

Installation

Appendix A. Installation

How to obtain KFormula

KFormula is part of the KDE project http://www.kde.org/.

KFormula can be found in the koffice package on ftp://ftp.kde.org/pub/kde/, the main FTP site of the KDE project.

Requirements

Requirements

Requirements

KFormula is part of KOffice on The KFormula home page You must have KOffice installed. KFormula will not work without the rest of KOffice

KDE Logo
Compilation and Installation

Compilation and Installation

Compilation and Installation

In order to compile and install KFormula on your system, type the following in the base directory of the KFormula distribution:

% ./configure
% make
% make install

Since KFormula uses autoconf and automake you should have no trouble compiling it. Should you run into problems please report them to the KDE mailing lists.

KDE Logo
Configuration

Configuration

Configuration

Some fonts will not work with KFormula. You will need to try several to achieve a satisfactory rendering.

KDE Logo
KDE Logo
KDE Logo