1

I'd like to set the top margin being equal to the left margin, but the left margin is auto-completed from the text width. I'm using geometry package.

I just want to do something like:

\documentclass[12pt, a4paper]{article}
\usepackage{geometry}
\geometry{
    textwidth = 38em, 
    top = left, 
}
3
  • @HarishKumar: I've tried that but it gives a crazy result, so maybe \leftmargin isn't related to this similarly to \topmargin. The left margin is autocompleted by geometry package from given text width and left–right margin ratio.
    – user87690
    Commented Aug 27, 2015 at 14:26
  • @HarishKumar: I think that my question isn't related to document class. I've added an example.
    – user87690
    Commented Aug 27, 2015 at 14:32
  • @HarishKumar: I'm using oneside, a4paper, 12pt, article. But how is it related to my question of how to relate top with left using geometry?
    – user87690
    Commented Aug 27, 2015 at 14:42

1 Answer 1

2

You can't use \leftmargin, as geometry mentions in the users' manual:

Each margin is measured from the corresponding edge of a paper. For example, left margin (inner margin) means a horizontal distance between the left (inner) edge of the paper and that of the total body. Therefore the left and top margins defined in geometry are different from the native dimensions \leftmargin and \topmargin.

geometry's left margin is stored in \Gm@lmargin, which you can access as a package option using

\makeatletter
\begingroup
\edef\x{\endgroup\noexpand\geometry{top=\Gm@lmargin}}\x
\makeatother

I would therefore use

\usepackage{geometry}
\geometry{
  textwidth = 38em
}
\makeatletter
\begingroup
\edef\x{\endgroup\noexpand\geometry{top=\Gm@lmargin}}\x
\makeatother
3
  • So it is really not supported by the package, you have to use a workaround. I suppose that I cannot use \geometry{textwidth=38em,top=\Gm@lmargin} since the correct left margin is not set yet, but why cannot I use \geometry{textwidth=38em}\geometry{top=\Gm@lmargin}?
    – user87690
    Commented Aug 27, 2015 at 14:58
  • @user87690: Good question...
    – Werner
    Commented Aug 27, 2015 at 15:16
  • I suppose I may hide the expansion trick in a macro: \newcommand\Expanded[1]{\begingroup\edef\x{\endgroup#1}\x} and then call simply \Expanded{\noexpand\geometry{top = \Gm@lmargin}}.
    – user87690
    Commented Aug 29, 2015 at 9:52

You must log in to answer this question.

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