Vent question - critical distance
I want to install a toilet on the second floor of our house. We have a very small room upstairs in the center of the house which is ideal for an upstairs 1/2 bath. The main 4" vent is on the gable end of the house about 26 feet away from where I want to install the new toilet. My first thought was that I could simply go straight up through the wall behind the toilet into the attic and then across the attic to connect to the main vent 26 feet away. But then I read about "critical distance" for venting purposes. Will my original plan work? Or do I need to go straight up through the roof from my new toilet and have a second vent pipe poking throught the roof?
I guess what has me confused is "Where is the critical distance measured from?" If I have a 4" vent coming out of the roof, can I run horizontally from that vent in the attic to connect to my fixture? Is the distance measured horizontally from my trap that point where the vent stack rises vertically through the roof? Or is it measured horizontally from my trap to a point where I can connect to the venting system as a whole?
Thanks in advance for your help!