14

Is it possible to indent whole paragraphs of source code in TeXMaker (or alternatively, in any LaTeX editor), so that intentation applies to all rows in paragraphs when the text is wrapped over several lines is the editor?

By default, TeXMaker intents the source code like the first code snippet below, whereas I would like indentation as in the second snippet, i.e. applied to the whole paragraph.

\begin{abstract}
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
sed do eiusmod tempor incididunt ut labore et dolore 
magna aliqua. Ut enim ad minim veniam, quis nostrud 
exercitation ullamco laboris nisi ut aliquip ex ea commodo 
consequat.
\end{abstract}

vs.

\begin{abstract}
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
    sed do eiusmod tempor incididunt ut labore et dolore 
    magna aliqua. Ut enim ad minim veniam, quis nostrud 
    exercitation ullamco laboris nisi ut aliquip ex ea commodo 
    consequat.
\end{abstract}
13

6 Answers 6

4

TeXstudio - originally called TexMakerX, a fork of Texmaker - apparently does the block indenting of word-wrapped paragraphs "out of the box". Here's a screenshot of a test I just did with my version of TeXstudio (version 2.6.2 running in Ubuntu 12.04):

enter image description here

1
  • 2
    This works even with hard-wrapping while soft-wrapping is shown here. Aug 5, 2013 at 2:28
4

As someone else suggested, it's in the edit menu. Furthermore, it seems to have a default keyboard shortcut:

Ctrl+>

I also note that the shortcut for unindent is:

Ctrl+<

4
  • 1
    This is no new information/answer on the question.
    – user31729
    Nov 12, 2014 at 15:24
  • I disagree. The user wanted a way to indent several lines of source in Texmaker without hassle. The provided keyboard shortcuts do that. Nov 12, 2014 at 15:34
  • Welcome to TeX.SX! I think this would not work on my Mac. For a detailed answer, you should always specify limitations of the proposed approach. Nov 12, 2014 at 15:42
  • Thank you! I already feel the warmth :) Go to the menu Options -> Configure TexMaker. In the "Configure TexMaker" window select "Shortcuts" from the left pane. In the actions you can find "Indent" and "Unindent" which were set to Ctrl+> and Ctrl+<, respectively, by default on my system. If you prefer you can descibe the shortcuts as Ctrl+Shift+. and Ctrl+Shift+, on my UK QWERTY keyboard. I'm using Texmaker 4.1 running on Ubuntu. Nov 12, 2014 at 16:04
3

"Edit" menu of Texmaker -> indent : will indent the selected text and Texmaker uses indentation memory.

On the snapshot, the text is not indented because this is the same line and not a block of different lines (Texmaker uses dynamic word-wrap : a line is automatically wrapped according to the width of the editor)

1

Emacs/AucTeX does not seem to do block indentation be default, but by some googling last night I found that it can be enabled by installing a script like adaptive-wrap (see also Auctex block indent). The difference can be seen below.

Without adaptive-wrap:

example without adaptive-wrap

With adaptive wrap:

example with adaptive-wrap

2
  • Without any extra script you can also use LaTeX -> Formatting and Marking -> Format Environment/Paragraph/Region/Section from the menu, or the corresponding key codes (C-c C-q C-e/p/r/s). This will pretty-print these parts of your code. Or you can press tab when a line is not indented.
    – Alex
    Aug 5, 2013 at 14:44
  • Yes, but that method inserts spaces and divide the lines into a width which fits the editor, whereas the script still keeps the letters/words on one long line? (if that was even remotely understandable... :) )
    – malin
    Aug 5, 2013 at 15:10
0

In TeXworks, you can highlight multiple lines of source code and press Ctrl+] (I imagine there's an analogous command if you're not using Windows) to indent them all. You can press Ctrl+[ to unindent them. I don't know if it will work in TeXMaker; it doesn't work for me in TeXstudio.

3
  • 2
    Welcome to TeX.SX! The questions is about TeXMaker and not about TeXworks.
    – Bobyandbob
    Aug 3, 2017 at 17:09
  • 2
    @Bobyandbob On the other hand, from the question: or alternatively, in any LaTeX editor. Aug 3, 2017 at 17:29
  • @HeikoOberdiek Yes you're right. I have to read more carefully.
    – Bobyandbob
    Aug 3, 2017 at 17:37
0

In Texmaker highlight multiple line and then press:

Ctrl and SHIFT and '>' to indent to right. Ctrl and SHIFT and '<' to indent to left.

You can also perform the same task from menu: 'Edit' menu and select 'Indent', Or Edit menu and select 'Unindent'

You must log in to answer this question.

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