1

Consider the example attached below, taken from the memoir package documentation.

I would like to be able to replicate how the words "lines" and "nearest" appear in the margins. For example, say I am defining Coulomb's Law, I would like "Coulomb's Law" to appear in the margin in a similar fashion when I write about it in the main body text.

EDIT: I would like to achieve this without the use of a list environment, which for example @Vinccool96 has provided.

EDIT 2: I would like the command to apply to a specific word in a body of text, and produce result as shown in the screenshot, while also retaining the word in the body of text without necessarily altering its in text appearance, just adding the word again in the margin with the \texttt{} font.

Example of what I would like to achieve

3
  • You are not by chance just looking for \marginpar?
    – user121799
    Commented Mar 30, 2019 at 19:51
  • I don't believe so. I would like for example to do the following: \command{word} and have the word appear both as in the screenshot provided in as well as in the body of text. Commented Mar 30, 2019 at 19:56
  • 1
    \documentclass{article} \usepackage{lipsum} \newcommand{\mykeyword}[1]{\reversemarginpar\marginpar{\texttt{#1}}\texttt{#1}} \begin{document} bla bla \mykeyword{word} bla \lipsum[1-7] bla bla \mykeyword{another word} bla \lipsum[8-12] \end{document}
    – user121799
    Commented Mar 30, 2019 at 20:08

3 Answers 3

1

It seems you simple want to write an important word into the margin of your document.

Please see the following MWE (important code marked with <=====)

\documentclass{article} 

\usepackage{blindtext} % <========================= to create dummy text
\usepackage{showframe} % <========= to visualize typing area and margins
\newcommand{\myimportant}[1]{%
  \marginpar{\texttt{#1}}#1% <========= text in margin same text in text
}


\begin{document} 
\blindtext
blafasel \myimportant{word} % <=========================================
blub \blindtext 

\end{document}

and its result:

text in margin

Be careful: too many \myimportant commands near to each other can result in ugly output ...

1
  • 1
    I suggested almost the same in my comment but the OP seems not to like it.
    – user121799
    Commented Mar 30, 2019 at 21:04
0

I uses the itemize environment with custom labels, the text is made with the \texttt{} command:

\documentclass{article}

\begin{document}

    \begin{itemize}
        \item[\texttt{lines}] This is similar to \texttt{classic}, but results in a 
        smaller final value.
        \item[\texttt{nearest}] The calculated value is the nearest to the given value
        while still maintaining the relationship
    \end{itemize}

\end{document}

3
  • How would I do this without the itemize environment, say when I am in text? Commented Mar 30, 2019 at 19:29
  • You asked how the memoir package creators did it, no? I looked at the .tex file they used to produce their documentation and gave you their source code (found here, it's the memman.tex file)
    – Vinccool96
    Commented Mar 30, 2019 at 19:37
  • Yes, I did ask how to replicate it, but mentioned that I would like to do this within the main body of text. I have added a clarification as my original question could be misleading. Commented Mar 30, 2019 at 19:43
0

In memoir you can use the \marginpar macro; see chapter 12 in the documentation (> texdoc memoir). For example:

\documentclass{memoir}
\newcommand*{\mymarginpar}[1]{\marginpar{#1}#1}
\begin{document}
This is similar to lines\marginpar{lines} but produces a smaller value.

The calculated value is \mymarginpar{nearest} to the given value while
still maintaining a relationship.
\end{document}

Depending on how you want everything to look you might want to add additional information (like fonts to use) in the \marginpar macro. read the manual for additional information.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .