Tag Archives: float

Several common methods of inserting pictures into latex documents

zz from: http://hepg.sdu.edu.cn/Service/tips/latex/latexfig.html#top & http://liqunsun.spaces.live.com/Blog/cns!285A08B51269F219!109.entry

Generally, latex only supports inserting EPS (encapsulated postscript) format graphics files directly, so we should try to get EPS format files before inserting pictures into latex documents.

all kinds of application software under UNIX can output the results in PS format, Most software can also output EPS format. If the software can only output PS format but not EPS format results, it can be converted to EPS format by ps2epsi command. Please refer to man ps2epsi’s instructions. If the image file format is bitmap graphics file, it can be converted to PS or EPS format file by display and convert tools of image magic package. See man page and man page for details

instructions

the output of windows software becomes PS / EPS file: please refer to the

“How to convert the output of software in Windows system into PS and EPS files”

Description in the column

 

Inserting pictures into latex documents is realized by using some latex graphics processing macro commands. Many macro commands support inserting EPS format graphics files into latex documents

(1) Using the macro command of includegraphics (graphicx package)

First of all, you need to add the following in the file description of latex document:

/usepackage{graphicx}

Then, it is quoted in the place where the image needs to be inserted:
/ includegraphics [height = height] {image file name} or / includegraphics [width = width] {image file name}
where “height” and “width” refer to the height and width of the image to be printed, and the unit must be given, which can be centimeter (CM) or inch (in), The image file name in the above command refers to the file name of the image file to be inserted. The image must be in EPS format

When inserting a picture with the macro command includegraphics of the graphicx package, you can also rotate the picture by:
/ includegraphics [height = height] [angle = rotation angle] {picture file name}

The inserted graphics are usually in EPS, PDF, JPG, PNG and other formats. Suppose the name is fig, and put it in the same directory of your tex document.
1. First add a sentence / usepackage {graphicx}
in the introduction area. 2. If you want to insert an inline graphic, you can directly use
/ includegraphics [width = 5in] {fig},
without adding a suffix.
This width is my most commonly used option, which can also be changed to other options.
3. If you want to insert floating graphics, use
/ begin {figure} [htbp]
/ centering / includgraphics [width = 3.5in] {fig}
/ caption {something} / label{ fig:1 }
/ end {figure}
4. For EPS graphics, the compilation process is latex, dvips, ps2pdf.
for PDF JPG PNG graphics, the compilation process is pdflatex

Use the include graphics macro command (graphics package) to:

It is troublesome to insert pictures with graphics package

(2) Using psfig macro command

First of all, you need to add the following in the file description of latex document:

/usepackage{psfig}

Then, it is quoted in the place where the picture needs to be inserted:
/ psfig {figure = picture file name, height = height} or / psfig {figure = picture file name, width = width}
where “height” and “width” refer to the height and width of the picture you want to print, and the unit bit must be given, which can be centimeter (CM) or inch (in), The image file name in the above command refers to the file name of the image file to be inserted. The image must be in EPS format

(3) use the epsfig macro command

The usage of epsfig macro command is exactly the same as that of psfig. The specific method is as follows:
first, add the following in the file description of latex document:

/usepackage{epsfig}

Then reference where you want to insert the image:

/ epsfig {figure = picture file name, height = height} or / epsfig {figure = picture file name, width = width}

The “height” and “width” refer to the height and width of the picture you want to print. The unit must be given, which can be centimeter (CM) or inch (in). The height and width can also be in the above format

The image file name in the above command refers to the file name of the image file to be inserted, and the image must be in EPS format

        

(4) Using EpsF macro command

The usage of EpsF macro command is as follows: first, add the following in the file description of latex document:

/usepackage{epsf}

Then, you can refer to:
/ epsfxsize = width / epsffile {image file name} or / epsfysize = height / epsffile {image file name} where you want to insert the image

The “height” and “width” refer to the height and width of the image to be printed. The unit must be given, which can be centimeter (CM) or inch (in). The height and width can also be given in the above format, so that the length width ratio of the original image can be changed. The image file name in the above command refers to the file name of the image file to be inserted, and the image must be in EPS format

 

(5) Latex? Picture control command, position control

Latex controls the position of the image by adding an exclamation point to ignore the “aesthetic” standard.
/ begin {figure} [! HTB]
/ usepackage {float}
/ begin {figure} [H]
insert it into the corresponding position of your code.

1, insert the side-by-side subgraph
/ usepackage {subfigure}

/ begin {figure} [H]
/ centering
/ subfigure [subfigurecaption] {
/ label{ Fig.sub .1}
/includegraphics[width=0.4/textwidth]{ figurename.eps }}
/subfigure[SubfigureCaption]{
/label{ Fig.sub .2}
/includegraphics[width=0.4/textwidth]{ figurename.eps }}
/caption{MainfigureCaption}
/label{ Fig.lable }
/ end {figure}

2, control the image position
if you don’t like latex to automatically arrange the image position, you can use the float package, and then
use / begin {figure} [H].
/ usepackage {float}
1, insert JPG image
in the command line environment, use the command:
ebb figure.jpg
Generating bounding box file figure.bb .
Use the following command:
/ includegraphics [width = 0.8/textwidth]{ figure.jpg }
PDF texify can be directly compiled into PDF file.
2, insert BMP image
there is no way to insert BMP image directly. The current method is to use
gimp to convert BMP into JPG, and then insert it according to the above method. When converting, do not use windows built-in painter, as the image quality is lost too much. With gimp or
fastone image viewer, the JPG quality is the highest, and the image quality is better.
3, insert JPG and EPS images at the same time
the insert command remains unchanged. When compiling, it uses latex and dvi2pdf, and the
images in both formats can be displayed.
Insert EPS picture
use / includegraphics [options] {file} command to insert EPS picture. The following is the simplest example:
/ documentclass {article}
/ usepackage {graphicx}% using the graphicx package
/ begin {document}
/ includegraphics{ file.eps }% insert the picture, insert it according to the original size of the picture
/ end {document}
note:
(1) EPS file and Tex file are placed in the same folder, which can be called only by the file name, without writing the path.
(2) Pdflatex cannot be used at compile time, an error will occur. Even if there are no mistakes, you can’t see the diagram. We should use latex compilation to generate DVI, and then dvi2ps, ps2pdf can see the figure.
Use [options] to specify the image size:
/ includegraphics [width = 3in]{ file.eps }
set the image width to 3 inches, and the image height will be automatically scaled.
/includegraphics[width=/testwidth]{ file.eps }
set the image width to the text width.
/includegraphics[width=0.8/textwidth]{ file.eps }
set the image width to 0.8 times the text width
/ includegraphics [width = / testwidth-2.0in]{ file.eps }
set the image width to be 2 inches less than the text width.
Use [options] to specify the image rotation angle:
/ includegraphics [angle = 270]{ file.eps }
rotate the image 270 degrees.
The two options are used at the same time, separated by commas:
/ includegraphics [width = / testwidth, angle = 270]{ file.eps }

 

A few useful articles on graph problems in latex

Graphics and Colour with LaTeX 

Online guide to illustration and color use in latex

Figure’ing and picture’ing latex (PS format)

The method of inserting PS graph and xfig graph into latex

Using imported graphics in latex 2e (PS format)

The illustration in latex is discussed in detail, including basic concepts, file formats and their mutual conversion, related software, etc. in addition, how to replace the characters in PS format pictures with latex format characters is also discussed, so as to solve the problem that some application software can not use special characters such as Greek alphabet and complex mathematical formula expressions

Latex maths and graphics (PS format)

It is mainly about the method of inserting pictures and formulas into latex.

this paper introduces the method of inserting pictures and formulas into latex

About Visio to EPS

Many people are used to drawing with Visio (including me), but Visio can’t export EPS format, so they have to rely on third-party software. Save it as *. EMF format through Visio, and then open it with OpenOffice draw to export it to EPS format. When exporting, you need to select the open image, so that after exporting EPS, only the content of *. EMF image will be included, and there will be no large blank. But the EPS image exported by this method will be out of shape, for example, the straight line will often be intermittent, and the “computer” shape I added in Visio will also have inexplicable shadows. Or maybe I didn’t set it up.

There is another better solution, the EPS file exported is perfect. In other words, the Visio graphics are printed into PDF by acrobat printer, and then cut by gsview (gsview4.8). The specific process is as follows:

1 edit the image file and save it as PDF file

Install acrobat, print the edited picture as PDF file under Visio and word

 

2 to EPS file

Open PDF file in acobat and select Save as EPS file

 

3. Reduce EPS files

Open EPS file with gsview, select File — & gt; PS to EPS, select auto cut, and save it as another *. EPS file

VS2010 debugging window flash solution

These days the development integration environment has been changed to VS2010, just started to use, some places are not very understand, by consulting the relevant documents, is now solved.
Take the VS2010 debugging window flash through the solution is as follows:
#include < iostream>
using namespace std;
void main()
int add(int,int,int);
float business (int);
int x, y, z, sum;
cout< < “Input x, y, z:”;
cin> > x> > y> > z;
the sum = add (x, y, z);
cout< <” sum=”< < sum< < endl;
cout< <” average=”< < average(sum)< < endl;
// system (” pause “);
}
}
Int add (int a, int b, int c)
{return (a+b+c); }
float business (int s)
{return (s/3.0); }
This is the test code.
The solution is as follows:
If you are compiling (F5), you can run the program (Ctrl+F5). If it is still flashing, use the following method to solve it.
method one:
1. If the c + + files, in the final to write a program before (return) add: system (” pause “);
= #include”stdlib.h”;
= #include”stdlib.h”; Then add: system(“pause”) at the end of the program (before the return).
Method 2:
. Right click on the current project – Properties
2> 3. Change the SUBSYSTEM configuration in System Options, select the first ‘/ CONSOLE’ in the drop-down menu and then select ‘Start Executing (Don’t Debug)’, that is Ctrl +F5;
This solves the flash window problem once and for all.
 

Configure glut in Ubuntu and implement basic OpenGL experiment on CodeBlocks platform

1. First, install GLUT. I selected “Download FreeGLUT” to install the command procedure:
http://freeglut.sourceforge.net/docs/install.php
$sudo apt-get install libxi-dev: error: X11/extensions/ xinput. h: No such file or directory
//after the installation, my computer inside the/usr/local/include/lib folder and set up some reference libraries and header files, etc

2. Configure Codeblocks:
Open Codeblocks, select the GLUT project, select New, enter the project name, and you will be prompted to specify the installation path for GLUT. You can specify it directly to /usr/ (I specified /usr/local/). If both of the above files are present, you should be able to set up the project without any problems.
in the end, one more thing, is to compile time there will be a mistake about Xxf86vm. Right-click on the project to open the project properties window and see the “Project Settings” TAB. Click on the “project ‘s build
Options “, then click on the “Linker Settings” TAB and delete the reference to xxf86VM to compile correctly.
3. Another easy way (just use Vim directly)
1). Install build-essential sudo apt-get Install build-essential // Install autotool
2). Install OpenGL sudo apt-get Install FreeGLUT 3-dev //
3). Use the command: : GCC simple.c-lGlut-o Simple at compile time
Where simple.c can use:

/*
 * GLUT Shapes Demo
 *
 * Written by Nigel Stewart November 2003
 *
 * This program is test harness for the sphere, cone
 * and torus shapes in GLUT.
 *
 * Spinning wireframe and smooth shaded shapes are
 * displayed until the ESC or q key is pressed.  The
 * number of geometry stacks and slices can be adjusted
 * using the + and - keys.
 */

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#include <stdlib.h>

static int slices = 16;
static int stacks = 16;

/* GLUT callback Handlers */

static void resize(int width, int height)
{
    const float ar = (float) width/(float) height;

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity() ;
}

static void display(void)
{
    const double t = glutGet(GLUT_ELAPSED_TIME)/1000.0;
    const double a = t*90.0;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3d(1,0,0);

    glPushMatrix();
        glTranslated(-2.4,1.2,-6);
        glRotated(60,1,0,0);
        glRotated(a,0,0,1);
        glutSolidSphere(1,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(0,1.2,-6);
        glRotated(60,1,0,0);
        glRotated(a,0,0,1);
        glutSolidCone(1,1,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(2.4,1.2,-6);
        glRotated(60,1,0,0);
        glRotated(a,0,0,1);
        glutSolidTorus(0.2,0.8,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(-2.4,-1.2,-6);
        glRotated(60,1,0,0);
        glRotated(a,0,0,1);
        glutWireSphere(1,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(0,-1.2,-6);
        glRotated(60,1,0,0);
        glRotated(a,0,0,1);
        glutWireCone(1,1,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(2.4,-1.2,-6);
        glRotated(60,1,0,0);
        glRotated(a,0,0,1);
        glutWireTorus(0.2,0.8,slices,stacks);
    glPopMatrix();

    glutSwapBuffers();
}


static void key(unsigned char key, int x, int y)
{
    switch (key)
    {
        case 27 :
        case 'q':
            exit(0);
            break;

        case '+':
            slices++;
            stacks++;
            break;

        case '-':
            if (slices>3 && stacks>3)
            {
                slices--;
                stacks--;
            }
            break;
    }

    glutPostRedisplay();
}

static void idle(void)
{
    glutPostRedisplay();
}

const GLfloat light_ambient[]  = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[]  = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };

const GLfloat mat_ambient[]    = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[]    = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[]   = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };

/* Program entry point */

int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitWindowSize(640,480);
    glutInitWindowPosition(10,10);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("GLUT Shapes");

    glutReshapeFunc(resize);
    glutDisplayFunc(display);
    glutKeyboardFunc(key);
    glutIdleFunc(idle);

    glClearColor(1,1,1,1);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);

    glEnable(GL_LIGHT0);
    glEnable(GL_NORMALIZE);
    glEnable(GL_COLOR_MATERIAL);
    glEnable(GL_LIGHTING);

    glLightfv(GL_LIGHT0, GL_AMBIENT,  light_ambient);
    glLightfv(GL_LIGHT0, GL_DIFFUSE,  light_diffuse);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);

    glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
    glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
    glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);

    glutMainLoop();

    return EXIT_SUCCESS;
}

To complete.