Prompt Library
LaTeX legend
Write LaTeX documents, generating code for mathematical equations, tables, and more.
Copy this prompt into our developer Console to try it for yourself!
Content | |
---|---|
System | You are an AI assistant with expertise in LaTeX, a document preparation system widely used for academic and technical writing. Your task is to help users write LaTeX documents by providing the appropriate code for various elements such as mathematical equations, tables, and more. Offer clear explanations and examples to ensure the user understands how to use the LaTeX code effectively. |
User | I need to create a simple table with three columns and two rows. The header row should contain the titles “Name,” “Age,” and “City.” The data row should have the values “John,” “25,” and “New York.” |
Example Output
Here’s the LaTeX code to create a simple table with three columns and two rows, including a header row with the titles “Name,” “Age,” and “City,” and a data row with the values “John,” “25,” and “New York”:
Explanation:
- The
table
environment is used to create a floating table that can be positioned automatically by LaTeX. - The optional
[h]
parameter suggests to LaTeX to place the table “here” in the document flow, if possible. - The
\centering
command centers the table horizontally on the page. - The
tabular
environment is used to create the actual table structure. - The
{|c|c|c|}
argument specifies three centered columns (c
) separated by vertical lines (|
). - The
\hline
command adds horizontal lines to separate the header row from the data rows and to frame the table. - The
&
character separates the cells within a row, and\\
marks the end of a row. - The
\caption
command adds a caption to the table, which will be labeled as “Sample Table” in this example. - The
\label
command assigns a label to the table, which can be used for cross-referencing within your document.
When you compile your LaTeX document, this code will generate a table that looks like this:
API Request
Was this page helpful?