> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/field-specific/06-knitting-patterns.md).

# Knitting patterns

## Introduction

LaTeX provides a special document class to make easier typesetting documents with knitting patterns and pictures. This article explains how to use the package [`knittingpattern`](https://ctan.org/pkg/knittingpattern?lang=en).

Using knitting patterns is straightforward. You just have to declare the right document class

```latex
\documentclass{knittingpattern}

\begin{document}

\title{Knitting patterns}
\author{Overleaf team}
\date{\today}
\maketitle

\cpyrght{Overleaf team}

\intro{
    Introductory text here. It will look better if it has the
    same height as the image next to it.
    Introductory text here. It will look better if it has the
    same height as the image next to it...
}{lion-logo}
```

![KnittingPatternsEx1OverleafV2.png](/files/0WeonvLYrxX2GqUl17Gy)

The command on top of the document

```latex
\documentclass{knittingpattern}
```

enables several commands to make easier to change the layout of some elements by means of some commands. For instance

* `\cpyrght{...}` Removes the page numbers and add a footnote. Intended for copyright notes.
* `\intro{}{}` Takes two parameters inside braces. The first one is some (introductory) text, the second one is an image. The text is printed on the left and the image next to it.

[Open an example of the `knitpattern` package in Overleaf](https://www.overleaf.com/project/new/template/19507?id=65965453\&templateName=Knitting+Patterns+Demo\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## Diagrams

To add an image containing a diagram **knittingpattern** provides a special command

```latex
\diagram{overleaf-logo}
```

![KnittingPatternsEx2OverleafV2.png](/files/VGpOZU1OkLAHbOTy9pjD)

The command `\diagram` prints a centred, bordered image whose width is a half of the page.

[Open an example of the `knitpattern` package in Overleaf](https://www.overleaf.com/project/new/template/19507?id=65965453\&templateName=Knitting+Patterns+Demo\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## Notes and remarks

If you need to highlight a special block of text within the document, there are two commands to add boxed notes and remarks to the document.

```latex
\definecolor{colour0}{HTML}{000000}
\definecolor{colour2}{HTML}{97DE76}
\definecolor{colour4}{HTML}{EDB668}

\begin{document}

\note{colour0}{colour2}{Materials}{
    Wool, some wool, and you may also need wool for the
    wool parts.
}

There's also this special command

\important{colour0}{colour4}{This note is very important.
That's why it's highlighted}
\end{document}
```

![KnittingPatternsEx3.png](/files/HHzPsm2f7hxeDDQZL9cE)

The command `\note{}{}{}{}` takes 4 parameters:

* the colour for the border,
* the background colour,
* a title and
* the text to be printed inside the box.

The colours use **xcolor** HTML syntax. See [Using colours in LaTeX](/latex/formatting/13-using-colors-in-latex.md) for more information.

The second command, `\important`, has essentially the same syntax as `\note`, but the title is omitted.

[Open an example of the `knitpattern` package in Overleaf](https://www.overleaf.com/project/new/template/19507?id=65965453\&templateName=Knitting+Patterns+Demo\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## Adding knitting instructions

The main purpose of a document about knitting is to actually provide directions about a knitting pattern. The package **knittingpatern** provides an environment that prints a table of instructions.

```latex
\documentclass{knittingpatern}
\definecolor{colour3}{HTML}{99CCFF}
\definecolor{colour5}{HTML}{CCFFCC}

\begin{document}
\begin{pattern}{colour3}{colour5}
Cast on & (st)\\
Instruction 1 & (st)\\
Instruction 2 & (st)\\
Instruction 3 & (st)\\
Instruction 4 & (st)\\
Instruction 5 & (st)\\
Instruction 6 & (st)\\
Instruction 7 & (st)\\
Instruction 8 & (st)\\
Instruction 9 & (st)\\
Instruction 10 & (st)\\
\quad\vdots & \quad\vdots\\
\end{pattern}
\end{document}
```

![KnittingPatternsEx4.png](/files/AeLMGeRVIv80rMoaMIiH)

The environment takes two parameters that determine the alternating colours used in the table to improve readability. See [Using colours in LaTeX](/latex/formatting/13-using-colors-in-latex.md) for more information about colour manipulation in LaTeX.

[Open an example of the `knitpattern` package in Overleaf](https://www.overleaf.com/project/new/template/19507?id=65965453\&templateName=Knitting+Patterns+Demo\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## Further reading

For more information see:

* [Creating your first LaTeX document](/latex/latex-basics/01-learn-latex-in-30-minutes.md)
* [Bold, italics and underlining](/latex/latex-basics/03-bold-italics-and-underlining.md)
* [Inserting Images](/latex/more-topics/27-inserting-images.md)
* [Positioning images and tables](/latex/figures-and-tables/02-positioning-images-and-tables.md)
* [Paragraph formatting](/latex/formatting/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [Using colours in LaTeX](/latex/formatting/13-using-colors-in-latex.md)
* [Font sizes, families, and styles](/latex/fonts/01-font-sizes-families-and-styles.md)
* [Font typefaces](/latex/fonts/02-font-typefaces.md)
* [The `knittingpattern` package documentation](https://ctan.org/pkg/knittingpattern?lang=en)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/field-specific/06-knitting-patterns.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
