When reading a pdf file, I use different colors for highlighting; for example to distinguish different ideas.

Is it possible to have a number of colors readily available when using pdf-tools. That is after highlighting, right-click > change color

  • It is. Every time you choose another color, it will get added to the 'readily available colors' (the listed colors after navigating to change-color). Does that answer your question? Jul 3, 2022 at 8:45
  • No, it does not answer the question because that way the colors for highlighting have to be selected every time you open emacs and that is what I would like to avoid
    – user25482
    Jul 3, 2022 at 13:30
  • A yes... I see. Well, it looks like @whitetrillium already posted a nice solution indeed! Jul 4, 2022 at 15:18

1 Answer 1

  1. Set your preferred colours
(setq pdf-annot-color-history '("red" "yellow" "blue"))
  1. While viewing the pdf file, do M-x pdf-annot-minor-mode
  2. Do C-c C-a m, which is same as M-x pdf-annot-add-markup-annotation
    • press ENTER.

      This chooses highlight as your choice. You will be prompted for a color with Color (default red).

    • Now, keep on pressing M-p (previous-history-element) until you see the color you want.

      Press ENTER to choose the color

With regard to choosing among "historical candidates", it is convenient to go with some completion framework.

  • If you are using helm, when prompted for a color, do M-x helm-minibuffer-history and select from the pre-configured colors.

I am using M-g M-h for helm-minibuffer-history. This is my own custom binding.

Here is a screenshot of what I see when I do C-c C-a m RET M-g M-h RET,

Choose color for PDF annotation using helm

  • Thanks for the detailed answer. (setq pdf-annot-color-history '("red" "yellow" "blue")) is what I was looking for
    – user25482
    Jul 4, 2022 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.